Skip to content
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

SAM doesn't work with Rancher Desktop #3715

Closed
melboyce opened this issue Mar 5, 2022 · 3 comments
Closed

SAM doesn't work with Rancher Desktop #3715

melboyce opened this issue Mar 5, 2022 · 3 comments

Comments

@melboyce
Copy link

melboyce commented Mar 5, 2022

Description:

I'm trying to move away from Docker Desktop and am trying Rancher Desktop instead. The SAM CLI reports no response from invoke container for <function-name> when trying sam local invoke. Note: standard docker commands seem to run fine (Rancher symlinks docker into /usr/local/bin). It may be worth mentioning that Rancher Desktop uses QEMU in the backend, via Lima.

Steps to reproduce:

  • install and configure Rancher Desktop (v1.1.1)
  • install aws-sam-cli
  • run sam local invoke for any lambda project

Observed result:

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build && sam local invoke --debug
2022-03-06 09:55:25,272 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-03-06 09:55:25,272 | Using config file: samconfig.toml, config environment: default
2022-03-06 09:55:25,272 | Expand command line arguments to:
2022-03-06 09:55:25,272 | --template_file=/Users/mel/r/lp/val/template.yml --no_event --layer_cache_basedir=/Users/mel/.aws-sam/layers-pkg --container_host=localhost --container_host_interface=127.0.0.1
2022-03-06 09:55:25,272 | local invoke command is called
2022-03-06 09:55:25,274 | No Parameters detected in the template
2022-03-06 09:55:25,283 | There is no customer defined id or cdk path defined for resource func, so we will use the resource logical id as the resource id
2022-03-06 09:55:25,284 | 1 stacks found in the template
2022-03-06 09:55:25,284 | No Parameters detected in the template
2022-03-06 09:55:25,288 | There is no customer defined id or cdk path defined for resource func, so we will use the resource logical id as the resource id
2022-03-06 09:55:25,288 | 1 resources found in the stack
2022-03-06 09:55:25,288 | No Parameters detected in the template
2022-03-06 09:55:25,293 | There is no customer defined id or cdk path defined for resource func, so we will use the resource logical id as the resource id
2022-03-06 09:55:25,294 | Found Serverless function with name='func' and CodeUri='./'
2022-03-06 09:55:25,294 | --base-dir is not presented, adjusting uri ./ relative to /Users/mel/r/lp/val/template.yml
2022-03-06 09:55:25,304 | Found one Lambda function with name 'func'
2022-03-06 09:55:25,304 | Invoking val (go1.x)
2022-03-06 09:55:25,304 | No environment variables found for function 'func'
2022-03-06 09:55:25,304 | Environment variables overrides data is standard format
2022-03-06 09:55:25,304 | Loading AWS credentials from session with profile 'None'
2022-03-06 09:55:25,310 | Resolving code path. Cwd=/Users/mel/r/lp/val, CodeUri=/Users/mel/r/lp/val
2022-03-06 09:55:25,310 | Resolved absolute path to code is /Users/mel/r/lp/val
2022-03-06 09:55:25,310 | Code /Users/mel/r/lp/val is not a zip/jar file
2022-03-06 09:55:25,329 | Skip pulling image and use local one: public.ecr.aws/sam/emulation-go1.x:rapid-1.40.1-x86_64.

2022-03-06 09:55:25,329 | Mounting /Users/mel/r/lp/val as /var/task:ro,delegated inside runtime container
2022-03-06 09:55:25,605 | Starting a timer for 60 seconds for function 'func'
2022-03-06 09:55:26,645 | Cleaning all decompressed code dirs
2022-03-06 09:55:26,645 | No response from invoke container for func
2022-03-06 09:55:26,648 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '3145117d-172c-4bf2-b5bc-226063543ba9', 'installationId': '403d296b-c7e9-4aaa-ae48-ecbd56cb1b9f', 'sessionId': 'a03f1bf2-0f34-4b79-bdc6-567c4c9afea4', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.10.2', 'samcliVersion': '1.40.1', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'metricSpecificAttributes': {'projectType': 'CFN'}, 'duration': 1375, 'exitReason': 'success', 'exitCode': 0}}]}
2022-03-06 09:55:27,374 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)

Expected result:

Some kind of output from the lambda.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: macOS Monterey (12.2.1)
  2. If using SAM CLI, sam --version: SAM CLI, version 1.40.1
  3. AWS region: ap-southeast-2
@jfuss jfuss transferred this issue from aws/serverless-application-model Mar 7, 2022
@jfuss
Copy link
Contributor

jfuss commented Mar 7, 2022

SAM CLI does not support Rancher Desktop at the moment. Please see #3595 where we are looking at options other than Docker.

Closing as dup.

@schlueter
Copy link

schlueter commented Feb 23, 2024

Because this comes up as the first result when Googling "aws sam rancher", this is the relevant comment from the thread mentioned above:
#3595 (comment)

For the rancher users ...

export DOCKER_HOST="unix://$HOME/.rd/docker.sock"

Or ensure that admin mode in Rancher is turned on (Settings > General > Administrator Access)

Maybe the sam cli could be updated to provide a more helpful response to sam local invoke than

Error: Running AWS SAM projects locally requires Docker. Have you got it installed and running?
Particularly as that is the response even when docker ps functions correctly with alternative docker providers such as Rancher.

@doteric
Copy link

doteric commented Jul 18, 2024

Hey 👋

Thank you @schlueter , setting the DOCKER_HOST env var to the mentioned value helped. However, now I'm receiving the following error:

PS > sam local start-api
No current session found, using default AWS::AccountId

Error: module 'socket' has no attribute 'AF_UNIX'
Traceback:
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
# ....
    sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
                         ^^^^^^^^^^^^^^

An unexpected error was encountered while executing "sam local start-api".

did you run into this problem by any chance?

Edit:
My problem was actually different, rancher was simply not starting up correctly due to a missing tool in WSL. All working fine now.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants