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

Bug: Sam build hanging in github-actions #7453

Closed
Jdldeveloper opened this issue Sep 7, 2024 · 3 comments
Closed

Bug: Sam build hanging in github-actions #7453

Jdldeveloper opened this issue Sep 7, 2024 · 3 comments
Labels

Comments

@Jdldeveloper
Copy link

Jdldeveloper commented Sep 7, 2024

Description:

I previously opened an issue (#7429) which seemed to be resolved with --use-container as part of the same build process.

However, as I tried to use a github action to build, it will consistently hang on Mounting ... inside runtime container step.

I've seen varying issues within the issue history but nothing really came of this that got resolved.

Steps to reproduce:

My repository sam-numpy-example contains merely this:

  1. A scaffold hello world sam application
  2. Added numpy as a dependency inside the codeuri as requirements.txt
  3. Added a github-actions.yml which checks out the code, sets up python, sets up sam (aws-actions/setup-sam@v2), configures AWS credentials from a repository secret and finally tries to run sam build --use-container --debug

You can see this actions workflow which hung on this step for 8 minutes before I cancelled it. In contrast, it builds in 15 seconds locally.

Observed result:

Run sam build --use-container --debug
	SAM CLI now collects telemetry to better understand customer needs.
	You can OPT OUT and disable telemetry collection by setting the
	environment variable SAM_CLI_TELEMETRY=0 in your shell.
	Thanks for your help!
	Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html
2024-09-07 16:37:10,590 | Config file location: /home/runner/work/sam-numpy-example/sam-numpy-example/samconfig.toml
2024-09-07 16:37:10,590 | Loading configuration values from [default.['build'].parameters] (env.command_name.section) in config file at '/home/runner/work/sam-numpy-example/sam-numpy-example/samconfig.toml'...
2024-09-07 16:37:10,591 | Configuration values successfully loaded.
2024-09-07 16:37:10,591 | Configuration values are: {'stack_name': 'sam-numpy-example', 'cached': True, 'parallel': True}
2024-09-07 16:37:10,595 | Using SAM Template at /home/runner/work/sam-numpy-example/sam-numpy-example/template.yaml
2024-09-07 16:37:10,615 | Using config file: samconfig.toml, config environment: default
2024-09-07 16:37:10,615 | Expand command line arguments to:
2024-09-07 16:37:10,615 | --template_file=/home/runner/work/sam-numpy-example/sam-numpy-example/template.yaml --use_container --parallel --mount_with=READ --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache --cached 
2024-09-07 16:37:10,650 | 'build' command is called
2024-09-07 16:37:10,650 | Starting Build use cache
2024-09-07 16:37:10,650 | Starting Build inside a container
2024-09-07 16:37:10,654 | No Parameters detected in the template
2024-09-07 16:37:10,697 | There is no customer defined id or cdk path defined for resource MyLambdaLayer, so we will use the resource logical id as the resource id
2024-09-07 16:37:10,697 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2024-09-07 16:37:10,697 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2024-09-07 16:37:10,698 | 0 stacks found in the template
2024-09-07 16:37:10,698 | No Parameters detected in the template
2024-09-07 16:37:10,715 | There is no customer defined id or cdk path defined for resource MyLambdaLayer, so we will use the resource logical id as the resource id
2024-09-07 16:37:10,715 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2024-09-07 16:37:10,715 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2024-09-07 16:37:10,716 | 3 resources found in the stack 
2024-09-07 16:37:10,716 | --base-dir is not presented, adjusting uri layers/ relative to /home/runner/work/sam-numpy-example/sam-numpy-example/template.yaml
2024-09-07 16:37:10,716 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2024-09-07 16:37:10,716 | --base-dir is not presented, adjusting uri hello_world/ relative to /home/runner/work/sam-numpy-example/sam-numpy-example/template.yaml
2024-09-07 16:37:10,716 | --base-dir is not presented, adjusting uri layers/ relative to /home/runner/work/sam-numpy-example/sam-numpy-example/template.yaml
2024-09-07 16:37:10,720 | 3 resources found in the stack 
2024-09-07 16:37:10,720 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2024-09-07 16:37:10,720 | Skip building layer without a build method: MyLambdaLayer
2024-09-07 16:37:10,721 | Skip building layer without a build method: MyLambdaLayer
2024-09-07 16:37:10,721 | Skip building layer without a build method: MyLambdaLayer
2024-09-07 16:37:10,721 | Skip building layer without a build method: MyLambdaLayer
2024-09-07 16:37:10,721 | Instantiating build definitions
2024-09-07 16:37:10,721 | No previous build graph found, generating new one
2024-09-07 16:37:10,721 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(python3.[12](https://github.com/Jdldeveloper/sam-numpy-example/actions/runs/10752897450/job/29821731327#step:6:13), /home/runner/work/sam-numpy-example/sam-numpy-example/hello_world, Zip, , 061a6000-e522-4905-ad2f-34e7fcfb8036, {}, {}, arm64, []), Function: Function({'function_id': 'HelloWorldFunction', 'name': 'HelloWorldFunction', 'functionname': 'HelloWorldFunction', 'runtime': 'python3.12', 'memory': None, 'timeout': 3, 'handler': 'app.lambda_handler', 'imageuri': None, 'packagetype': 'Zip', 'imageconfig': None, 'codeuri': '/home/runner/work/sam-numpy-example/sam-numpy-example/hello_world', 'environment': None, 'rolearn': None, 'layers': [<samcli.lib.providers.provider.LayerVersion object at 0x7fd2a5021210>], 'events': {'HelloWorld': {'Type': 'Api', 'Properties': {'Path': '/hello', 'Method': 'get', 'RestApiId': 'ServerlessRestApi'}}}, 'metadata': {'SamResourceId': 'HelloWorldFunction'}, 'inlinecode': None, 'codesign_config_arn': None, 'architectures': ['arm64'], 'function_url_config': 
2024-09-07 16:37:10,723 | Async execution started
2024-09-07 16:37:10,723 | Invoking function functools.partial(<bound method ParallelBuildStrategy.build_single_function_definition of <samcli.lib.build.build_strategy.ParallelBuildStrategy object at 0x7fd2a5023450>>, <samcli.lib.build.build_graph.FunctionBuildDefinition object at 0x7fd2a502[13](https://github.com/Jdldeveloper/sam-numpy-example/actions/runs/10752897450/job/29821731327#step:6:14)90>)
2024-09-07 16:37:10,723 | Running incremental build for runtime python3.12 for following resources (HelloWorldFunction)
2024-09-07 [16](https://github.com/Jdldeveloper/sam-numpy-example/actions/runs/10752897450/job/29821731327#step:6:17):37:10,724 | Waiting for async results
2024-09-07 16:37:10,724 | Cache is invalid, running build and copying resources for following functions (HelloWorldFunction)
2024-09-07 16:37:10,724 | Building codeuri: /home/runner/work/sam-numpy-example/sam-numpy-example/hello_world runtime: python3.12 architecture: arm64 functions: HelloWorldFunction
2024-09-07 16:37:10,724 | Building to following folder /home/runner/work/sam-numpy-example/sam-numpy-example/.aws-sam/build/HelloWorldFunction
2024-09-07 16:37:10,730 | Checking free port on 127.0.0.1:8364
Fetching public.ecr.aws/sam/build-python3.12:latest-arm64 Docker container image............................................................................................................................................................................................................................................................................................................................................................................................................................................................................
[20](https://github.com/Jdldeveloper/sam-numpy-example/actions/runs/10752897450/job/29821731327#step:6:21)24-09-07 16:37:41,347 | Mounting /home/runner/work/sam-numpy-example/sam-numpy-example/hello_world as /tmp/samcli/source:ro,delegated, inside runtime container

Expected result:

I'd expect this build to complete or provide any update as to what's going on.

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

This is on an ubuntu-latest github-hosted runner

@Jdldeveloper Jdldeveloper added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Sep 7, 2024
@hnnasit
Copy link
Contributor

hnnasit commented Sep 16, 2024

Hi @Jdldeveloper, thanks for reporting the issue. I believe what's happening here is since the architecture is set to arm64 in the template.yaml file, sam build -u is trying to pull the arm64 based image on a x86 based ubuntu github runner which is really slow. Could you try changing the architecture to x86_64 here instead and see if it makes a difference. I tried changing the architecture and the build here was much faster.

@hnnasit hnnasit added type/question area/build sam build command and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Sep 16, 2024
@Jdldeveloper
Copy link
Author

@hnnasit great catch, thanks so much! That was in fact the issue and it built much faster.

Copy link
Contributor

⚠️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.

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

No branches or pull requests

2 participants