aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.51k stars 1.17k forks source link

Function OOM Fail #7570

Open Marshall-Qiao opened 8 hours ago

Marshall-Qiao commented 8 hours ago

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

Marshall-Qiao commented 8 hours ago

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