Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes microsoft#3454

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
  • Loading branch information
freddydk and freddydk committed Mar 30, 2024
1 parent d3c2600 commit a98151d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 51 deletions.
53 changes: 2 additions & 51 deletions ContainerHandling/Get-BestGenericImageName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,57 +51,8 @@ try {
else {
$genericImageNameSetting = $bcContainerHelperConfig.genericImageName.Replace('{1}', $ltscVersion)
}
$repo = $genericImageNameSetting.Split(':')[0]
$tag = $genericImageNameSetting.Split(':')[1].Replace('{0}','*')
if ($tag.indexOf('*') -lt 0) {
$genericImageNameSetting
}
else {
$failureDelay = 2
while ($true) {
$imagetags = Get-BcContainerImageTags -imageName $repo
if ($imagetags) {
$ver = [Version]"0.0.0.0"
# $tag can be *-filesonly, *-filesonly-dev, *-dev or other patterns
# * is the Windows version OS version
$versions = $imagetags.tags |
Where-Object { $_ -like $tag -and [System.Version]::TryParse($_.SubString($tag.indexOf('*'), $_.length-$tag.length+1), [ref]$ver) } |
ForEach-Object { [System.Version]($_.SubString($tag.indexOf('*'), $_.length-$tag.length+1)) }
break
}
else {
if ($failureDelay -gt 32) {
throw "Unable to download image tags for $repo"
}
Write-Host -ForegroundColor Yellow "Unable to download image tags for $repo, retrying in $failureDelay seconds"
Start-Sleep -Seconds $failureDelay
$failureDelay = $failureDelay * 2
}
}

$genericImageName = ""
$myversions = $versions | Where-Object { $_.Major -eq $hostOsVersion.Major -and $_.Minor -eq $hostOsVersion.Minor -and $_.Build -eq $hostOsVersion.Build } | Sort-Object
if (-not $myversions) {
if (-not $onlyMatchingBuilds) {
if ($hostOsVersion.Build -eq 19043 -or $hostOsVersion.Build -eq 19044 -or $hostOsVersion.Build -eq 19045) {
# 21H1 doesn't work well with 20H2 servercore images - grab 2004 if no corresponding image exists
Write-Host -ForegroundColor Yellow "INFO: Windows 10 21H1/21H2 images are not yet available, using 2004 as these are found to work better than 20H2 on 21H1/21H2"
$myversions = $versions | Where-Object { $_.Build -eq 19041 } | Sort-Object
}
else {
$myversions = $versions | Sort-Object
}
}
}
if ($myversions) {
$version = $myversions | Where-Object { $_ -le $hostOsVersion } | Select-Object -Last 1
if (-not $version) {
$version = $myversions | Select-Object -First 1
}
$genericImageName = [string]::format($genericImageNameSetting, $version.ToString())
}
$genericImageName
}

return $genericImageNameSetting.Replace('{0}', $ltscVersion).Replace('{1}', $ltscVersion)
}
catch {
TrackException -telemetryScope $telemetryScope -errorRecord $_
Expand Down
1 change: 1 addition & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
6.0.13
Issue 3452 Error when running Run-AlValidation : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Issue 3454 DockerDo : Cannot bind argument to parameter 'imageName' because it is an empty string.

6.0.12
Issue 3432 New-BcContainerWizard stopped working after generic images with ltsc2016, ltsc2019 and ltsc2022 was introduced
Expand Down

0 comments on commit a98151d

Please sign in to comment.