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

Increase token expiration and retry until compatible token #7239

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
wiktork marked this conversation as resolved.
Show resolved Hide resolved

$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