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]: AzureCLI seems to ignore SIGINT #20209

Closed
5 of 7 tasks
WhiteTomX opened this issue Jul 26, 2024 · 2 comments
Closed
5 of 7 tasks

[BUG]: AzureCLI seems to ignore SIGINT #20209

WhiteTomX opened this issue Jul 26, 2024 · 2 comments

Comments

@WhiteTomX
Copy link

New issue checklist

Task name

Azure CLI

Task version

2.242.0

Issue Description

When cancelling a pipeline containing a long running Azure CLI step, this step is not gracefully shut down.

This is annoying as we use it to run Terraform. In case of a cancellation, that may break or at least lock our terraform state.

May be related to #19390

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Ubuntu 22.04.4 LTS

Relevant log output

2024-07-26T07:56:42.3235905Z .
2024-07-26T07:56:43.9277480Z ##[debug]Re-evaluate condition on job cancellation for step: 'Test cancellation'.
2024-07-26T07:56:43.9286141Z ##[error]The Operation will be canceled. The next steps may not contain expected logs.
2024-07-26T07:56:43.9516272Z ##[error]The operation was canceled.
2024-07-26T07:56:43.9521812Z ##[debug]System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at System.Threading.CancellationToken.ThrowIfCancellationRequested()
   at Microsoft.VisualStudio.Services.Agent.Util.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in /mnt/vss/_work/1/s/src/Agent.Sdk/ProcessInvoker.cs:line 384
   at Microsoft.VisualStudio.Services.Agent.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in /mnt/vss/_work/1/s/src/Microsoft.VisualStudio.Services.Agent/ProcessInvoker.cs:line 329
   at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, Boolean continueAfterCancelProcessTreeKillAttempt, TimeSpan sigintTimeout, TimeSpan sigtermTimeout, Boolean useGracefulShutdown, CancellationToken cancellationToken) in /mnt/vss/_work/1/s/src/Agent.Worker/Handlers/StepHost.cs:line 85
   at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.NodeHandler.RunAsync() in /mnt/vss/_work/1/s/src/Agent.Worker/Handlers/NodeHandler.cs:line 255
   at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsyncInternal() in /mnt/vss/_work/1/s/src/Agent.Worker/TaskRunner.cs:line 446
   at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync() in /mnt/vss/_work/1/s/src/Agent.Worker/TaskRunner.cs:line 76
   at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken) in /mnt/vss/_work/1/s/src/Agent.Worker/StepsRunner.cs:line 264
2024-07-26T07:56:43.9525730Z ##[section]Finishing: Test cancellation

Full task logs with system.debug enabled

 2024-07-26T07:56:16.9988516Z ##[debug]Evaluating condition for step: 'Test cancellation'
2024-07-26T07:56:16.9989639Z ##[debug]Evaluating: SucceededNode()
2024-07-26T07:56:16.9989928Z ##[debug]Evaluating SucceededNode:
2024-07-26T07:56:16.9991654Z ##[debug]=> True
2024-07-26T07:56:16.9992033Z ##[debug]Result: True
2024-07-26T07:56:16.9992365Z ##[section]Starting: Test cancellation
2024-07-26T07:56:17.0001139Z ==============================================================================
2024-07-26T07:56:17.0001485Z Task         : Azure CLI
2024-07-26T07:56:17.0001580Z Description  : Run Azure CLI commands against an Azure subscription in a PowerShell Core/Shell script when running on Linux agent or PowerShell/PowerShell Core/Batch script when running on Windows agent.
2024-07-26T07:56:17.0001883Z Version      : 2.242.0
2024-07-26T07:56:17.0001966Z Author       : Microsoft Corporation
2024-07-26T07:56:17.0002069Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cli
2024-07-26T07:56:17.0002245Z ==============================================================================
2024-07-26T07:56:17.0657542Z ##[debug]Resource Utilization warnings is disabled, switch "DISABLE_RESOURCE_UTILIZATION_WARNINGS" variable to "true" if you want to enable it
2024-07-26T07:56:17.1883327Z ##[debug]Using node path: /home/vsts/agents/3.241.0/externals/node16/bin/node
2024-07-26T07:56:17.3903580Z ##[debug]agent.TempDirectory=/home/vsts/work/_temp
2024-07-26T07:56:17.3912252Z ##[debug]loading inputs and endpoints
2024-07-26T07:56:17.3917688Z ##[debug]loading INPUT_CONNECTEDSERVICENAMEARM
2024-07-26T07:56:17.3929018Z ##[debug]loading INPUT_SCRIPTTYPE
2024-07-26T07:56:17.3931759Z ##[debug]loading INPUT_SCRIPTLOCATION
2024-07-26T07:56:17.3934098Z ##[debug]loading INPUT_SCRIPTPATH
2024-07-26T07:56:17.3936313Z ##[debug]loading INPUT_INLINESCRIPT
2024-07-26T07:56:17.3938552Z ##[debug]loading INPUT_POWERSHELLERRORACTIONPREFERENCE
2024-07-26T07:56:17.3940791Z ##[debug]loading INPUT_ADDSPNTOENVIRONMENT
2024-07-26T07:56:17.3944608Z ##[debug]loading INPUT_USEGLOBALCONFIG
2024-07-26T07:56:17.3947018Z ##[debug]loading INPUT_CWD
2024-07-26T07:56:17.3950026Z ##[debug]loading INPUT_FAILONSTANDARDERROR
2024-07-26T07:56:17.3973405Z ##[debug]loading INPUT_POWERSHELLIGNORELASTEXITCODE
2024-07-26T07:56:17.3973805Z ##[debug]loading INPUT_VISIBLEAZLOGIN
2024-07-26T07:56:17.3974140Z ##[debug]loading INPUT_KEEPAZSESSIONACTIVE
2024-07-26T07:56:17.3974598Z ##[debug]loading INPUT_FAILONSTDERR
2024-07-26T07:56:17.3974963Z ##[debug]loading ENDPOINT_AUTH_
2024-07-26T07:56:17.3980867Z ##[debug]loading ENDPOINT_AUTH_SCHEME_
2024-07-26T07:56:17.3981293Z ##[debug]loading ENDPOINT_AUTH_PARAMETER__TENANTID
2024-07-26T07:56:17.3981698Z ##[debug]loading ENDPOINT_AUTH_PARAMETER__SCOPE
2024-07-26T07:56:17.3982120Z ##[debug]loading ENDPOINT_AUTH_PARAMETER__WORKLOADIDENTITYFEDERATIONSUBJECT
2024-07-26T07:56:17.3982582Z ##[debug]loading ENDPOINT_AUTH_PARAMETER__WORKLOADIDENTITYFEDERATIONISSUER
2024-07-26T07:56:17.3983018Z ##[debug]loading ENDPOINT_AUTH_PARAMETER__SERVICEPRINCIPALID
2024-07-26T07:56:17.3983425Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2024-07-26T07:56:17.3983791Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2024-07-26T07:56:17.3984168Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2024-07-26T07:56:17.3986737Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2024-07-26T07:56:17.3987098Z ##[debug]loaded 25
2024-07-26T07:56:17.3994231Z ##[debug]Agent.ProxyUrl=undefined
2024-07-26T07:56:17.3994608Z ##[debug]Agent.CAInfo=undefined
2024-07-26T07:56:17.3994929Z ##[debug]Agent.ClientCert=undefined
2024-07-26T07:56:17.3995256Z ##[debug]Agent.SkipCertValidation=undefined
2024-07-26T07:56:17.5552454Z ##[debug]check path : /home/vsts/work/_tasks/AzureCLI_46e4be58-730b-4389-8a2f-ea10b3e5e815/2.242.0/task.json
2024-07-26T07:56:17.5560119Z ##[debug]adding resource file: /home/vsts/work/_tasks/AzureCLI_46e4be58-730b-4389-8a2f-ea10b3e5e815/2.242.0/task.json
2024-07-26T07:56:17.5563992Z ##[debug]system.culture=en-US
2024-07-26T07:56:17.5579209Z ##[debug]which 'az'
2024-07-26T07:56:17.5595962Z ##[debug]found: '/usr/bin/az'
2024-07-26T07:56:17.5603597Z ##[debug]Feature flag AZP_AZURECLIV2_SETUP_PROXY_ENV not found. Returning false as default.
2024-07-26T07:56:17.5610935Z ##[debug]scriptType=bash
2024-07-26T07:56:17.5612088Z ##[debug]scriptLocation=inlineScript
2024-07-26T07:56:17.5612628Z ##[debug]scriptArguments=undefined
2024-07-26T07:56:17.5615762Z ##[debug]Agent.TempDirectory=/home/vsts/work/_temp
2024-07-26T07:56:17.5617714Z ##[debug]inlineScript=#!/bin/bash

signal_caught() {
echo Shutting Down
exit 1
}
trap signal_caught SIGHUP SIGINT SIGQUIT SIGTERM
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
sleep 3
echo .
2024-07-26T07:56:17.5624396Z ##[debug]which 'bash'
2024-07-26T07:56:17.5655758Z ##[debug]found: '/usr/bin/bash'
2024-07-26T07:56:17.5657087Z ##[debug]which '/usr/bin/bash'
2024-07-26T07:56:17.5657742Z ##[debug]found: '/usr/bin/bash'
2024-07-26T07:56:17.5658797Z ##[debug]/usr/bin/bash arg: /home/vsts/work/_temp/azureclitaskscript1721980577561.sh
2024-07-26T07:56:17.5660882Z ##[debug]cwd=/home/vsts/work/1/s
2024-07-26T07:56:17.5662247Z ##[debug]scriptLocation=inlineScript
2024-07-26T07:56:17.5663677Z ##[debug]failOnStandardError=false
2024-07-26T07:56:17.5665040Z ##[debug]testing directory '/home/vsts/work/1/s'
2024-07-26T07:56:17.5689517Z ##[debug]which 'az'
2024-07-26T07:56:17.5693692Z ##[debug]found: '/usr/bin/az'
2024-07-26T07:56:17.5694726Z ##[debug]/usr/bin/az arg: --version
2024-07-26T07:56:17.5695094Z ##[debug]/usr/bin/az arg: --version
2024-07-26T07:56:17.5697997Z ##[debug]exec tool: /usr/bin/az
2024-07-26T07:56:17.5698357Z ##[debug]exec tool: /usr/bin/az
2024-07-26T07:56:17.5699406Z ##[debug]arguments:
2024-07-26T07:56:17.5699781Z ##[debug]arguments:
2024-07-26T07:56:17.5718378Z ##[debug] --version
2024-07-26T07:56:17.5718735Z ##[debug] --version
2024-07-26T07:56:17.5719179Z [command]/usr/bin/az --version
2024-07-26T07:56:18.8025642Z azure-cli 2.62.0
2024-07-26T07:56:18.8026374Z
2024-07-26T07:56:18.8027422Z core 2.62.0
2024-07-26T07:56:18.8027737Z telemetry 1.1.0
2024-07-26T07:56:18.8028033Z
2024-07-26T07:56:18.8128959Z Extensions:
2024-07-26T07:56:18.8129355Z azure-devops 1.0.1
2024-07-26T07:56:18.8129424Z
2024-07-26T07:56:18.8129549Z Dependencies:
2024-07-26T07:56:18.8129670Z msal 1.28.1
2024-07-26T07:56:18.8129877Z azure-mgmt-resource 23.1.1
2024-07-26T07:56:18.8129944Z
2024-07-26T07:56:18.8130135Z Python location '/opt/az/bin/python3'
2024-07-26T07:56:18.8130373Z Extensions directory '/opt/az/azcliextensions'
2024-07-26T07:56:18.8130455Z
2024-07-26T07:56:18.8130764Z Python (Linux) 3.11.8 (main, Jul 4 2024, 02:23:40) [GCC 11.4.0]
2024-07-26T07:56:18.8130872Z
2024-07-26T07:56:18.8131024Z Legal docs and information: aka.ms/AzureCliLegal
2024-07-26T07:56:18.8131106Z
2024-07-26T07:56:18.8131147Z
2024-07-26T07:56:18.8131315Z Your CLI is up-to-date.
2024-07-26T07:56:18.8132478Z ##[debug]useGlobalConfig=false
2024-07-26T07:56:18.8132823Z ##[debug]Agent.TempDirectory=/home/vsts/work/_temp
2024-07-26T07:56:18.8133152Z ##[debug]Agent.TempDirectory=/home/vsts/work/_temp
2024-07-26T07:56:18.8133390Z Setting AZURE_CONFIG_DIR env variable to: /home/vsts/work/_temp/.azclitask
2024-07-26T07:56:18.8133715Z ##[debug]connectedServiceNameARM=
2024-07-26T07:56:18.8134096Z ##[debug] data environment = AzureCloud
2024-07-26T07:56:18.8134323Z Setting active cloud to: AzureCloud
2024-07-26T07:56:18.8134937Z ##[debug]which 'az'
2024-07-26T07:56:18.8135230Z ##[debug]found: '/usr/bin/az'
2024-07-26T07:56:18.8135531Z ##[debug]/usr/bin/az arg: cloud set -n AzureCloud
2024-07-26T07:56:18.8135848Z ##[debug]/usr/bin/az arg: cloud set -n AzureCloud
2024-07-26T07:56:18.8136146Z ##[debug]exec tool: /usr/bin/az
2024-07-26T07:56:18.8136448Z ##[debug]exec tool: /usr/bin/az
2024-07-26T07:56:18.8136727Z ##[debug]arguments:
2024-07-26T07:56:18.8137107Z ##[debug]arguments:
2024-07-26T07:56:18.8137376Z ##[debug] cloud
2024-07-26T07:56:18.8137639Z ##[debug] cloud
2024-07-26T07:56:18.8137902Z ##[debug] set
2024-07-26T07:56:18.8138163Z ##[debug] set
2024-07-26T07:56:18.8138420Z ##[debug] -n
2024-07-26T07:56:18.8138680Z ##[debug] -n
2024-07-26T07:56:18.8138947Z ##[debug] AzureCloud
2024-07-26T07:56:18.8139219Z ##[debug] AzureCloud
2024-07-26T07:56:18.8139508Z [command]/usr/bin/az cloud set -n AzureCloud
2024-07-26T07:56:19.7289730Z ##[debug]Agent environment resources - Disk: / Available 21170.00 MB out of 74244.00 MB, Memory: Used 757.00 MB out of 6921.00 MB, CPU: Usage 63.30%
2024-07-26T07:56:21.9931418Z ##[debug]connectedServiceNameARM=
2024-07-26T07:56:21.9932613Z ##[debug] auth scheme = WorkloadIdentityFederation
2024-07-26T07:56:21.9936916Z ##[debug] auth scheme = WorkloadIdentityFederation
2024-07-26T07:56:21.9937553Z ##[debug] data SubscriptionID =
2024-07-26T07:56:21.9938205Z ##[debug]visibleAzLogin=true
2024-07-26T07:56:21.9939600Z ##[debug] auth param serviceprincipalid = ***
2024-07-26T07:56:21.9940246Z ##[debug] auth param tenantid =
2024-07-26T07:56:21.9941152Z ##[debug]System.JobId=4b990335-4057-5eaf-9854-a37a4c72b5e4
2024-07-26T07:56:21.9941727Z ##[debug]System.PlanId=61713326-f973-47c7-abed-9920dc6ae959
2024-07-26T07:56:21.9942255Z ##[debug]System.TeamProjectId=
2024-07-26T07:56:21.9942846Z ##[debug]System.HostType=build
2024-07-26T07:56:21.9943826Z ##[debug]System.CollectionUri=https://dev.azure.com//
2024-07-26T07:56:21.9944228Z ##[debug]Getting credentials for local feeds
2024-07-26T07:56:21.9964485Z ##[debug]SYSTEMVSSCONNECTION exists true
2024-07-26T07:56:21.9964872Z ##[debug]Got auth token
2024-07-26T07:56:22.4892878Z ##[debug]Processed: ##vso[task.setsecret]***
2024-07-26T07:56:22.4895783Z ##[debug]which 'az'
2024-07-26T07:56:22.4896131Z ##[debug]found: '/usr/bin/az'
2024-07-26T07:56:22.4897532Z ##[debug]/usr/bin/az arg: login --service-principal -u "" --tenant "" --allow-no-subscriptions --federated-token ""
2024-07-26T07:56:22.4898963Z ##[debug]/usr/bin/az arg: login --service-principal -u "" --tenant "" --allow-no-subscriptions --federated-token ""
2024-07-26T07:56:22.4899448Z ##[debug]exec tool: /usr/bin/az
2024-07-26T07:56:22.4899786Z ##[debug]exec tool: /usr/bin/az
2024-07-26T07:56:22.4900108Z ##[debug]arguments:
2024-07-26T07:56:22.4900425Z ##[debug]arguments:
2024-07-26T07:56:22.4900733Z ##[debug] login
2024-07-26T07:56:22.4901036Z ##[debug] login
2024-07-26T07:56:22.4901351Z ##[debug] --service-principal
2024-07-26T07:56:22.4901697Z ##[debug] --service-principal
2024-07-26T07:56:22.4902018Z ##[debug] -u
2024-07-26T07:56:22.4902328Z ##[debug] -u
2024-07-26T07:56:22.4902677Z ##[debug] ***
2024-07-26T07:56:22.4903028Z ##[debug] ***
2024-07-26T07:56:22.4903337Z ##[debug] --tenant
2024-07-26T07:56:22.4903644Z ##[debug] --tenant
2024-07-26T07:56:22.4903981Z ##[debug]
2024-07-26T07:56:22.4904366Z ##[debug]
2024-07-26T07:56:22.4904721Z ##[debug] --allow-no-subscriptions
2024-07-26T07:56:22.4905062Z ##[debug] --allow-no-subscriptions
2024-07-26T07:56:22.4905398Z ##[debug] --federated-token
2024-07-26T07:56:22.4906008Z ##[debug] --federated-token
2024-07-26T07:56:22.4907175Z ##[debug] ***
2024-07-26T07:56:22.4908295Z ##[debug] ***
2024-07-26T07:56:22.4910747Z [command]/usr/bin/az login --service-principal -u *** --tenant --allow-no-subscriptions --federated-token ***
2024-07-26T07:56:23.7562744Z [
2024-07-26T07:56:23.7563419Z {
2024-07-26T07:56:23.7563641Z "cloudName": "AzureCloud",
2024-07-26T07:56:23.7564521Z "homeTenantId": "",
2024-07-26T07:56:23.7564888Z "id": "",
2024-07-26T07:56:23.7565129Z "isDefault": true,
2024-07-26T07:56:23.7565355Z "managedByTenants": [],
2024-07-26T07:56:23.7565677Z "name": "",
2024-07-26T07:56:23.7572495Z "state": "Enabled",
2024-07-26T07:56:23.7573161Z "tenantId": "",
2024-07-26T07:56:23.7573413Z "user": {
2024-07-26T07:56:23.7574162Z "name": "***",
2024-07-26T07:56:23.7574410Z "type": "servicePrincipal"
2024-07-26T07:56:23.7574634Z }
2024-07-26T07:56:23.7574829Z }
2024-07-26T07:56:23.7575007Z ]
2024-07-26T07:56:23.7575515Z ##[debug]which 'az'
2024-07-26T07:56:23.7575901Z ##[debug]found: '/usr/bin/az'
2024-07-26T07:56:23.7576338Z ##[debug]/usr/bin/az arg: account set --subscription ""
2024-07-26T07:56:23.7576856Z ##[debug]/usr/bin/az arg: account set --subscription ""
2024-07-26T07:56:23.7577288Z ##[debug]exec tool: /usr/bin/az
2024-07-26T07:56:23.7577662Z ##[debug]exec tool: /usr/bin/az
2024-07-26T07:56:23.7578028Z ##[debug]arguments:
2024-07-26T07:56:23.7578385Z ##[debug]arguments:
2024-07-26T07:56:23.7578754Z ##[debug] account
2024-07-26T07:56:23.7579107Z ##[debug] account
2024-07-26T07:56:23.7579457Z ##[debug] set
2024-07-26T07:56:23.7579804Z ##[debug] set
2024-07-26T07:56:23.7580158Z ##[debug] --subscription
2024-07-26T07:56:23.7580583Z ##[debug] --subscription
2024-07-26T07:56:23.7580983Z ##[debug]
2024-07-26T07:56:23.7581409Z ##[debug]
2024-07-26T07:56:23.7581858Z [command]/usr/bin/az account set --subscription
2024-07-26T07:56:24.3044985Z ##[debug]keepAzSessionActive=false
2024-07-26T07:56:24.3045817Z ##[debug]addSpnToEnvironment=true
2024-07-26T07:56:24.3046738Z ##[debug]exec tool: /usr/bin/bash
2024-07-26T07:56:24.3047099Z ##[debug]arguments:
2024-07-26T07:56:24.3047418Z ##[debug] /home/vsts/work/_temp/azureclitaskscript1721980577561.sh
2024-07-26T07:56:24.3047698Z [command]/usr/bin/bash /home/vsts/work/_temp/azureclitaskscript1721980577561.sh
2024-07-26T07:56:24.7322572Z ##[debug]Agent environment resources - Disk: / Available 21170.00 MB out of 74244.00 MB, Memory: Used 730.00 MB out of 6921.00 MB, CPU: Usage 36.07%
2024-07-26T07:56:27.3132728Z .
2024-07-26T07:56:29.7312363Z ##[debug]Agent environment resources - Disk: / Available 21170.00 MB out of 74244.00 MB, Memory: Used 731.00 MB out of 6921.00 MB, CPU: Usage 25.20%
2024-07-26T07:56:30.3150722Z .
2024-07-26T07:56:33.3172577Z .
2024-07-26T07:56:34.7304285Z ##[debug]Agent environment resources - Disk: / Available 21170.00 MB out of 74244.00 MB, Memory: Used 731.00 MB out of 6921.00 MB, CPU: Usage 19.50%
2024-07-26T07:56:36.3193652Z .
2024-07-26T07:56:39.3214998Z .
2024-07-26T07:56:39.7334991Z ##[debug]Agent environment resources - Disk: / Available 21170.00 MB out of 74244.00 MB, Memory: Used 739.00 MB out of 6921.00 MB, CPU: Usage 15.97%
2024-07-26T07:56:42.3235905Z .
2024-07-26T07:56:43.9277480Z ##[debug]Re-evaluate condition on job cancellation for step: 'Test cancellation'.
2024-07-26T07:56:43.9286141Z ##[error]The Operation will be canceled. The next steps may not contain expected logs.
2024-07-26T07:56:43.9516272Z ##[error]The operation was canceled.
2024-07-26T07:56:43.9521812Z ##[debug]System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at System.Threading.CancellationToken.ThrowIfCancellationRequested()
at Microsoft.VisualStudio.Services.Agent.Util.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in /mnt/vss/_work/1/s/src/Agent.Sdk/ProcessInvoker.cs:line 384
at Microsoft.VisualStudio.Services.Agent.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in /mnt/vss/_work/1/s/src/Microsoft.VisualStudio.Services.Agent/ProcessInvoker.cs:line 329
at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, Boolean continueAfterCancelProcessTreeKillAttempt, TimeSpan sigintTimeout, TimeSpan sigtermTimeout, Boolean useGracefulShutdown, CancellationToken cancellationToken) in /mnt/vss/_work/1/s/src/Agent.Worker/Handlers/StepHost.cs:line 85
at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.NodeHandler.RunAsync() in /mnt/vss/_work/1/s/src/Agent.Worker/Handlers/NodeHandler.cs:line 255
at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsyncInternal() in /mnt/vss/_work/1/s/src/Agent.Worker/TaskRunner.cs:line 446
at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync() in /mnt/vss/_work/1/s/src/Agent.Worker/TaskRunner.cs:line 76
at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken) in /mnt/vss/_work/1/s/src/Agent.Worker/StepsRunner.cs:line 264
2024-07-26T07:56:43.9525730Z ##[section]Finishing: Test cancellation

Repro steps

trigger: none
stages:
  - stage: az_cli
    jobs:
      - job: az_cli
        steps:
          - task: AzureCLI@2
            displayName: "Test cancellation"
            inputs:
              azureSubscription: ti-test
              addSpnToEnvironment: true
              scriptType: bash
              failOnStdErr: true
              scriptLocation: inlineScript
              inlineScript: |
                #!/bin/bash

                signal_caught() {
                    echo Shutting Down
                    exit 1
                }
                trap signal_caught SIGHUP SIGINT SIGQUIT SIGTERM
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
                sleep 3
                echo .
@WhiteTomX WhiteTomX added the bug label Jul 26, 2024
@github-actions github-actions bot added Area: Release triage Area: ABTT Akvelon Build Tasks Team area of work Task: Bash labels Jul 26, 2024
@v-schhabra v-schhabra removed Area: ABTT Akvelon Build Tasks Team area of work Task: Bash labels Jul 26, 2024
@WhiteTomX
Copy link
Author

For anyone stumbling across this: Our workaround for now is to just ignore cancellations all together:

  - task: Bash@3
    displayName: "Test if Pipeline is running"
    inputs:
      targetType: "inline"
      script: |
        set -e
        echo "##vso[task.setvariable variable=stepBeforeRan]true"
  - task: AzureCLI@2
    displayName: "Plan Terraform"
    condition: and(always(), eq(variables['stepBeforeRan'], 'true'))

Copy link

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

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

No branches or pull requests

2 participants