New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dev config flag for fixing lambda invoke on macOS in host mode #7367
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor nits!
@@ -208,6 +211,9 @@ def _build_executor_endpoint(self, service_endpoint: ServiceEndpoint) -> Executo | |||
self.id, | |||
) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch 👁️
I grouped the container_address
assignment at the bottom for better readability.
@@ -208,6 +211,9 @@ def _build_executor_endpoint(self, service_endpoint: ServiceEndpoint) -> Executo | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes a lot of sense and reduces clutter because the constructor can stay generic this way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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=asf
Relevant test case:
tests.integration.awslambda.test_lambda.TestLambdaFeatures.test_invocation_type_request_response
Background
There is also a long discussion thread about this issue in the moby project.
LocalStack Workarounds
TEST_SKIP_LOCALSTACK_START=1
TEST_PATH="tests/integration/awslambda/test_lambda_common.py" make test-docker-mount
pip 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_EXPOSE
and conditionally expose a free TCP port in the lambda container.