aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Bug: sam sync with python causes endless cpu saturation

Open cshenrik opened this issue 3 months ago • 10 comments

Description:

When running sam sync --watch --region us-east-1 on a python project, the sam sync process utilizes 100% cpu until I kill it (after at least 30 minutes)

Steps to reproduce:

  1. Create a new python project using sam init.
  2. Use python3.11
  3. Run sam deploy --guided
  4. Run sam sync --watch --region us-east-1

After it has deployed the application and the CPU utilization has gone down, it suddenly goes to 100% and stays there.

Observed result:

The last part of the output from sam sync:

2024-05-13 21:53:37,488 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,489 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,490 | There is no customer defined id or cdk path defined for resource ServerlessHttpApi, so we will use the resource logical id as the resource id                                                 
2024-05-13 21:53:37,491 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,492 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,493 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ServerlessHttpApi is ServerlessHttpApi                                                              
2024-05-13 21:53:37,493 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,495 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,496 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,497 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,498 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,499 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,501 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,503 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,503 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,505 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,506 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,507 | 3 resources found in the stack                                                                                                                                                                
2024-05-13 21:53:37,508 | Found Serverless function with name='CreateSignedUrlFunction' and CodeUri='create_signed_url'                                                                                                 
2024-05-13 21:53:37,510 | --base-dir is not presented, adjusting uri create_signed_url relative to <<<<REDACTED>>>>                                                
2024-05-13 21:53:37,513 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,514 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,515 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ServerlessHttpApi is ServerlessHttpApi                                                              
2024-05-13 21:53:37,516 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,517 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,518 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ServerlessHttpApi is ServerlessHttpApi                                                              
2024-05-13 21:53:37,519 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,519 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,520 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ServerlessHttpApi is ServerlessHttpApi                                                              
2024-05-13 21:53:37,521 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ImageBucket is ImageBucket                                                                          
2024-05-13 21:53:37,522 | Sam customer defined id is more priority than other IDs. Customer defined id for resource CreateSignedUrlFunction is CreateSignedUrlFunction                                                  
2024-05-13 21:53:37,523 | Sam customer defined id is more priority than other IDs. Customer defined id for resource ServerlessHttpApi is ServerlessHttpApi                                                              
2024-05-13 21:53:37,524 | CodeTrigger not created as CodeUri or DefinitionUri is missing for ServerlessHttpApi.                                                                                                         
2024-05-13 21:53:37,525 | Skipped infra sync as the local template is in sync with the cloud template.```


### Expected result:
`Sam sync` should use almost no cpu when no changes are being made.


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

<!-- Either provide the following info (for AWS SAM CLI v1.68.0 or before) or paste the output of `sam --info` (AWS SAM CLI v1.69.0 or after). -->

1. OS: Ubuntu 22.04.4 LTS
6. `sam --version`: SAM CLI, version 1.116.0
7. AWS region: us-east-1

Paste the output of sam --info here

{
  "version": "1.116.0",
  "system": {
    "python": "3.11.8",
    "os": "Linux-6.5.0-28-generic-x86_64-with-glibc2.35"
  },
  "additional_dependencies": {
    "docker_engine": "26.1.0",
    "aws_cdk": "2.97.0 (build d7cf3be)",
    "terraform": "1.5.7"
  },
  "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"
  ]
}

cshenrik avatar May 13 '24 20:05 cshenrik