Add dev config flag for fixing lambda invoke on macOS in host mode#7367
Add dev config flag for fixing lambda invoke on macOS in host mode#7367
Conversation
| ) | ||
| executor_endpoint = ExecutorEndpoint(self.id, service_endpoint=service_endpoint) | ||
| if config.LAMBDA_ASF_DEV_PORT_EXPOSE: | ||
| executor_endpoint.container_address = "localhost" |
There was a problem hiding this comment.
It would be nice to set self.ip as well, so the contract for get_address is not broken.
We are not currently using it, but still.
There was a problem hiding this comment.
good catch 👁️
I grouped the container_address assignment at the bottom for better readability.
| self.id, | ||
| ) | ||
| executor_endpoint = ExecutorEndpoint(self.id, service_endpoint=service_endpoint) | ||
| if config.LAMBDA_ASF_DEV_PORT_EXPOSE: |
There was a problem hiding this comment.
Can we merge that whole if block with the first one in start? It seems unnecessary that this happens at object creation time. We set the executor endpoint IP in the not-port-expose path in start() as well.
Especially get_free_tcp_port can take some time, so I would rather have it in the start method.
There was a problem hiding this comment.
Yes, that makes a lot of sense and reduces clutter because the constructor can stay generic this way
dfangl
left a comment
There was a problem hiding this comment.
One minor thing again (to set self.ip correctly), then its good to go from my side!
localstack/services/awslambda/invocation/docker_runtime_executor.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Daniel Fangl <daniel.fangl@localstack.cloud>
dfangl
left a comment
There was a problem hiding this comment.
LGTM! Great work tackling this!
|
Updated naming as discussed:
|
|
Just gave this a try on my Mac in host mode - works like a charm, great job @joe4dev 🚀 |
|
Glad to hear it works 👍 |
Co-authored by @dominikschubert
Problem
The new lambda provider requires bi-directional communication (host <=> lambda container), which breaks host mode in macOS because the lambda container is not reachable via IPv4 in bridge mode.
Hence, invoking any lambda fails while the lambda container waits for an invocation (i.e., during
"blocking the credentials service") after a connection timeout with the errorConnection to 172.17.0.2 timed out.Enable new lambda provider:
PROVIDER_OVERRIDE_LAMBDA=asfRelevant test case:
tests.integration.awslambda.test_lambda.TestLambdaFeatures.test_invocation_type_request_responseBackground
There is also a long discussion thread about this issue in the moby project.
LocalStack Workarounds
TEST_SKIP_LOCALSTACK_START=1TEST_PATH="tests/integration/awslambda/test_lambda_common.py" make test-docker-mountpip install -e⇒ delete
-v $$PACKAGES_DIR/moto:/opt/code/localstack/.venv/lib/python3.10/site-packages/moto/from test-docker-mount-code in the MakefileThanks, @dfangl for the hints 🙏
Potential macOS networking Workarounds (not tested)
Suggested Changes
Introduce a dev config flag
LAMBDA_DEV_PORT_EXPOSEand conditionally expose a free TCP port in the lambda container.