Skip to content

Commit

Permalink
Increase token expiration and retry until compatible token (#7239)
Browse files Browse the repository at this point in the history
  • Loading branch information
jander-msft authored Aug 31, 2024
1 parent 98619ba commit d4679c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
19 changes: 12 additions & 7 deletions eng/common/core-templates/steps/get-delegation-sas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ steps:
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
# Calculate the expiration of the SAS token and convert to UTC
$expiry = (Get-Date).AddHours(${{ parameters.expiryInHours }}).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
# Temporarily work around a helix issue where SAS tokens with / in them will cause incorrect downloads
# of correlation payloads. See https://github.com/dotnet/dnceng/issues/3484
$sas = ""
do {
# Calculate the expiration of the SAS token and convert to UTC
$expiry = (Get-Date).AddHours(${{ parameters.expiryInHours }}).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
$sas = az storage container generate-sas --account-name ${{ parameters.storageAccount }} --name ${{ parameters.container }} --permissions ${{ parameters.permissions }} --expiry $expiry --auth-mode login --as-user -o tsv
$sas = az storage container generate-sas --account-name ${{ parameters.storageAccount }} --name ${{ parameters.container }} --permissions ${{ parameters.permissions }} --expiry $expiry --auth-mode login --as-user -o tsv
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to generate SAS token."
exit 1
}
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to generate SAS token."
exit 1
}
} while($sas.IndexOf('/') -ne -1)
if ('${{ parameters.base64Encode }}' -eq 'true') {
$sas = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($sas))
Expand Down
3 changes: 2 additions & 1 deletion eng/pipelines/jobs/test-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ jobs:
displayName: Hydrate Node.js Installation Non-Linux

# Populate dotnetbuilds-internal-container-read-token for Helix
- template: /eng/common/templates/steps/enable-internal-runtimes.yml
- template: /eng/common/templates-official/steps/enable-internal-runtimes.yml
parameters:
outputVariableName: 'dotnetbuilds-internal-container-read-token'
base64Encode: false
expiryInHours: 2 # Match the job timeout; Helix can take a long time to process tests depending on queue depth

- ${{ else }}:
- ${{ if ne(parameters.osGroup, 'Windows') }}:
Expand Down

0 comments on commit d4679c2

Please sign in to comment.