aws/aws-sam-cli

Function OOM Fail

Marshall-Qiao opened this issue · 4 comments

Description:

When I use command to start my project
sam build && sam local invoke
It failed and only got a remind

Mounting /Users/userName/PycharmProjects/projectName/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated, inside runtime container                                                               
No response from invoke container for HelloWorldFunction                                                                                                                                                   
Function 'HelloWorldFunction' timed out after 30 seconds 

and reminding my computer uses an M3 chip, I doubt that problem, before I changed my project Architectures from x86_64 to arm64 because I could't use sam build command

   HelloWorldFunction:
    Type: AWS::Serverless::Function
    DependsOn:
      - MountTargetA
      - MountTargetB
    Properties:
      CodeUri: src/
      Handler: app.lambda_surrounded_handler
      Runtime: python3.12
      Architectures:
        - arm64

Steps to reproduce:

When I use command
sam build && sam local invoke --debug

Observed result:

4-10-15 19:56:39,792 | Checking free port on 127.0.0.1:8313                                                                                                                                             
2024-10-15 19:56:39,812 | Using local image: samcli/lambda-python:3.12-arm64-c857bb16baf52c9ee3208a3c7.                                                                                                    
                                                                                                                                                                                                           
2024-10-15 19:56:39,815 | Mounting /Users/qiaoyuanshou/PycharmProjects/uwcssa_be/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated, inside runtime container                                     
2024-10-15 19:56:42,977 | Starting a timer for 30 seconds for function 'HelloWorldFunction'                                                                                                                
2024-10-15 19:56:42,980 | Getting lock for the key localhost-8313                                                                                                                                          
2024-10-15 19:56:42,981 | Waiting to retrieve the lock (localhost-8313) to start invocation                                                                                                                
2024-10-15 19:56:43,112 | Getting lock for the key localhost-8313                                                                                                                                          
2024-10-15 19:56:43,113 | Waiting to retrieve the lock (localhost-8313) to start invocation                                                                                                                
2024-10-15 19:56:43,328 | Getting lock for the key localhost-8313                                                                                                                                          
2024-10-15 19:56:43,330 | Waiting to retrieve the lock (localhost-8313) to start invocation                                                                                                                
2024-10-15 19:56:43,771 | [Container state] OOMKilled False                                                                                                                                                
2024-10-15 19:56:44,402 | Cleaning all decompressed code dirs                                                                                                                                              
2024-10-15 19:56:44,404 | No response from invoke container for HelloWorldFunction   

I see the docker has the images, if I run,things like

docker run -i -t 69b1148c354f /bin/bash
WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v1) and no specific platform was requested

16 Oct 2024 00:02:11,186 [INFO] (rapid) exec '/var/runtime/bootstrap' (cwd=/var/task, handler=)

Expected result:

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

  1. OS: IOS M3 max chips
  2. sam --version: SAM CLI, version 1.125.0
  3. AWS region: us-east-2
# Paste the output of `sam --info` here

{
  "version": "1.125.0",
  "system": {
    "python": "3.8.20",
    "os": "macOS-15.0.1-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "27.1.1",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

By the way, my friend could run this project locally using his computer( with an M1 chip).

I've tried to re-produce this issue with M1 machine. I was able to build & invoke a python3.12 runtime lambda function with both X86 and arm64.

Since you mentioned that your friend can also run it, can you try to update or re-install Docker on your machine?

It works. My method is to uninstall and reinstall everything (aws-cli \sam\colima\docker desktop, etc.). This time I did not install colima, and used the latest version of docker desktop (be careful not to link from the Amazon documentation), and then compiled and deployed locally. Although it now reports some errors in the project layer, I can try to solve it myself.

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.