aws / aws/aws-toolkit-azure-devops

LambdaNETCoreDeploy task fails when run simultaneously multiple time on the same host for different pipelines

Open
#481 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
258
Forks
114
PR merge metrics
No merged PRs in 30d

Description

Background: Running the task from an Azure DevOps Pipeline on a Windows Agent Machine.

Inside the LambdaNETCoreDeploy@1 task one of things that gets run is this command:

dotnet tool update -g Amazon.Lambda.Tools

This command can cause the dotnet-lambda.exe install to get messed up if multiple pipelines are running the command at the same time on the same build machine. So this is a difficult bug to recreate. We had a series of scheduled jobs running at the same time that were creating this issue with some regularity . The only way we have found to resolve the issue is to rename the dotnet-lambda.exe executable. To reduce the incidence of the issue we have staggered the times when we run our scheduled jobs that run the LambdaNETCoreDeploy@1 task. This issue will still occur for us though I believe even though it should only be rarely now when manually submitted pipelines happen to be run at the same time on same build machine and get to running the above command at the same time. It would nice to have a resolution to this problem as it is a definite "gotcha" that people have posted about in a number of places. The most helpful one for me in understanding is the issue and that I have borrowed from to report this to the develop team is: https://issuehint.com/issue/aws/aws-toolkit-azure-devops/416.

Here is the typical error message that this issue shows (see below).

Configuring credentials for task
...configuring AWS credentials from service endpoint 'cacbb57d-6030-40b2-85d4-d97cf0163111'
...endpoint defines role-based credentials for role ***.
Processing Lambda project at E:\ADOAgent2\_work\75\s\src\bsd-ldex-transmission-response-api
Reading existing aws-lambda-tools-defaults.json
Configuring region for task
...configured to use region us-west-2, defined in task.
E:\ADOAgent2\_work\_tool\dotnet\dotnet.exe tool install -g Amazon.Lambda.Tools
Failed to create shell shim for tool 'amazon.lambda.tools ': Command 'dotnet-lambda' conflicts with an existing command from another tool.
Tool 'amazon.lambda.tools ' failed to install.
E:\ADOAgent2\_work\_tool\dotnet\dotnet.exe tool update -g Amazon.Lambda.Tools
Tool 'amazon.lambda.tools ' failed to update due to the following:
Failed to create shell shim for tool 'amazon.lambda.tools ': Command 'dotnet-lambda' conflicts with an existing command from another tool.
Tool 'amazon.lambda.tools ' failed to install.
##[error]Unable to install global Amazon.Lambda.Tools ! The old package based version of Amazon.Lambda.Tools is now deprecated. Newer .NET core versions will need to use a newer hosted agent and the global tools (which this task auto installs). Refer to Microsoft's guide for the correct hosted agent for which hosted agent you need to use newer .NET Core versions:https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted
E:\ADOAgent2\_work\_tool\dotnet\dotnet.exe restore
Determining projects to restore...
All projects are up-to-date for restore.
Beginning Serverless Deployment
Performing package-only build of serverless application, output template will be placed in E:\ADOAgent2\_work\75\a\bsd-ldex-transmission-response-api-template.yaml
C:\Users\s.cld.adoagent\.dotnet\tools\dotnet-lambda.exe package-ci -ot E:\ADOAgent2\_work\75\a\bsd-ldex-transmission-response-api-template.yaml --region us-west-2 --s3-bucket bsd-ldex-transmission-response-deployment-bucket-dev-main --disable-interactive true
The application to execute does not exist: 'C:\Users\s.cld.adoagent\.dotnet\tools\.store\amazon.lambda.tools\5.4.4\amazon.lambda.tools\5.4.4\tools\netcoreapp3.1\any\dotnet-lambda.dll'.
##[error]Error: The process 'C:\Users\s.cld.adoagent\.dotnet\tools\dotnet-lambda.exe' failed with exit code 2147516570
Function Name/ARN: arn:aws:lambda:us-west-2:624313876423:function:bsd-ldex-transmission-response-writer-dev-main
Mode of deployment: deployment package

Inside the LambdaNETCoreDeploy@1 task one of things that gets run is this command:

dotnet tool update -g Amazon.Lambda.Tools

This causes the install to get messed up if multiple pipelines are running the command at the same time. We had scheduled jobs running at the same time that were creating this issue often.
The only way we have found to resolve the issue is to rename the dotnet-lambda.exe executable. To reduce the incidence of the issue we have staggered the times when we run our scheduled jobs
that run the LambdaNETCoreDeploy@1 task. This issue will still occur for us though I believe even though it should only be very rarely. It would nice to have a resolution to this problem as it is a definite "gotcha" that people have posted about in a number of places.
The most helpful one for me that I have borrowed from to report this to the develop team is: https://issuehint.com/issue/aws/aws-toolkit-azure-devops/416.

Here is the typical error message that this issue shows:

Configuring credentials for task
...configuring AWS credentials from service endpoint 'cacbb57d-6030-40b2-85d4-d97cf0163111'
...endpoint defines role-based credentials for role ***.
Processing Lambda project at E:\ADOAgent2\_work\75\s\src\bsd-ldex-transmission-response-api
Reading existing aws-lambda-tools-defaults.json
Configuring region for task
...configured to use region us-west-2, defined in task.
E:\ADOAgent2\_work\_tool\dotnet\dotnet.exe tool install -g Amazon.Lambda.Tools
Failed to create shell shim for tool 'amazon.lambda.tools ': Command 'dotnet-lambda' conflicts with an existing command from another tool.
Tool 'amazon.lambda.tools ' failed to install.
E:\ADOAgent2\_work\_tool\dotnet\dotnet.exe tool update -g Amazon.Lambda.Tools
Tool 'amazon.lambda.tools ' failed to update due to the following:
Failed to create shell shim for tool 'amazon.lambda.tools ': Command 'dotnet-lambda' conflicts with an existing command from another tool.
Tool 'amazon.lambda.tools ' failed to install.
##[error]Unable to install global Amazon.Lambda.Tools ! The old package based version of Amazon.Lambda.Tools is now deprecated. Newer .NET core versions will need to use a newer hosted agent and the global tools (which this task auto installs). Refer to Microsoft's guide for the correct hosted agent for which hosted agent you need to use newer .NET Core versions:https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted
E:\ADOAgent2\_work\_tool\dotnet\dotnet.exe restore
Determining projects to restore...
All projects are up-to-date for restore.
Beginning Serverless Deployment
Performing package-only build of serverless application, output template will be placed in E:\ADOAgent2\_work\75\a\bsd-ldex-transmission-response-api-template.yaml
C:\Users\s.cld.adoagent\.dotnet\tools\dotnet-lambda.exe package-ci -ot E:\ADOAgent2\_work\75\a\bsd-ldex-transmission-response-api-template.yaml --region us-west-2 --s3-bucket bsd-ldex-transmission-response-deployment-bucket-dev-main --disable-interactive true
The application to execute does not exist: 'C:\Users\s.cld.adoagent\.dotnet\tools\.store\amazon.lambda.tools\5.4.4\amazon.lambda.tools\5.4.4\tools\netcoreapp3.1\any\dotnet-lambda.dll'.
##[error]Error: The process 'C:\Users\s.cld.adoagent\.dotnet\tools\dotnet-lambda.exe' failed with exit code 2147516570
Function Name/ARN: arn:aws:lambda:us-west-2:624313876423:function:bsd-ldex-transmission-response-writer-dev-main
Mode of deployment: deployment package

Contributor guide

Open the contributing guide

Research direction

Start at the LambdaNETCoreDeploy@1 task entry point and trace the dotnet tool install/update commands. Reproduce concurrent runs on a Windows Azure DevOps agent, focusing on the shared global Amazon.Lambda.Tools installation and dotnet-lambda shim. Done means simultaneous pipelines no longer produce shim conflicts or a missing dotnet-lambda.dll, and deployment completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.