Skip to content

Automatically use latest release#588

Open
AvrumFeldman wants to merge 3 commits intomicrosoft:Mainfrom
AvrumFeldman:DynamicVersion
Open

Automatically use latest release#588
AvrumFeldman wants to merge 3 commits intomicrosoft:Mainfrom
AvrumFeldman:DynamicVersion

Conversation

@AvrumFeldman
Copy link
Copy Markdown

I updated the script to by default use the latest releases of the packages instead of relying on hardcoded versions. I still left the option for hardcoded versions in case someone wants to use specific versions.

@AvrumFeldman
Copy link
Copy Markdown
Author

I see now I need to fix some code. Please hold off on approving the pull request.

@AvrumFeldman
Copy link
Copy Markdown
Author

Ok, I just tested my last commit and it's working as expected.

I did notice that CNI is being downloaded twice, once in New-ContainerTransparentNetwork and another time in Install-Containerd. In the New-ContainerTransparentNetwork the version was hardcoded without the ability to define the version (even though there is a parameter for static version. In my pull request I just hardcoded to always use the latest version. The question is whether

  • We leave it like this.
  • Or maybe either eliminate the redundant downloading and installation (will require moving install-containerd to be executed before New-ContainerTransparentNetwork in Install-ContainerDHost).
  • Or I can add the dynamic option in New-ContainerTransparentNetwork just like I did in Install-Containerd.

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.

8 similar comments
@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.

@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

This issue has been open for 30 days with no updates.
no assignees, please provide an update or close this issue.

@smiezah-msft smiezah-msft requested a review from Copilot April 14, 2026 17:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the containerd runtime installer script to default to pulling the latest upstream GitHub releases when versions aren’t explicitly provided.

Changes:

  • Makes Containerd/NerdCTL/WinCNI version parameters optional (no longer hardcoded defaults).
  • Adds GitHub API calls to detect and download the latest release assets for Containerd, NerdCTL, and WinCNI.
  • Updates WinCNI download in the network setup path to use latest release assets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

curl.exe -LO https://github.com/microsoft/windows-container-networking/releases/download/v0.3.0/windows-container-networking-cni-amd64-v0.3.0.zip
Expand-Archive -Path .\windows-container-networking-cni-amd64-v0.3.0.zip -DestinationPath $containerdPath
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/microsoft/windows-container-networking/releases/latest"
$url = ($ReleaseAssets.assets | ? name -Match "64.+zip$")
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

($ReleaseAssets.assets | ? ...) can return multiple matching assets; in that case $url.browser_download_url / $url.name become arrays and curl.exe / Expand-Archive will receive System.Object[] (or otherwise fail). Select a single deterministic asset (e.g., Select-Object -First 1, or stronger filtering on an exact asset name) and consider failing fast with a clear error if no matches are found.

Suggested change
$url = ($ReleaseAssets.assets | ? name -Match "64.+zip$")
$matchingAssets = $ReleaseAssets.assets | Where-Object { $_.name -match "64.+zip$" } | Sort-Object -Property name
if (-not $matchingAssets) {
throw "No windows-container-networking release asset matching '64.+zip$' was found."
}
$url = $matchingAssets | Select-Object -First 1

Copilot uses AI. Check for mistakes.
Comment on lines +578 to +581
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/containerd/containerd/releases/latest"
$Release = ($ReleaseAssets.assets | ? name -Match "Windows.+64.+gz$")
$URL = $Release.browser_download_url
$ContainerdZip = $Release.Name
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above: the asset filter can match multiple items, making $Release.browser_download_url / $Release.Name arrays and breaking Copy-File. Make the selection deterministic (pick exactly one asset) and handle the 'no asset matched' case explicitly so failures are understandable.

Copilot uses AI. Check for mistakes.
$URL = "https://github.com/containerd/nerdctl/releases/download/v$NerdCTLVersion/$NerdCTLZip"
} else {
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/containerd/nerdctl/releases/latest"
$Release = ($ReleaseAssets.assets | ? name -Match "Windows.+64.+gz$")
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the same multi-match failure mode as the containerd block. Ensure exactly one asset is selected (or tighten the regex to match a single expected filename) and error out clearly if none/too many matches are found.

Suggested change
$Release = ($ReleaseAssets.assets | ? name -Match "Windows.+64.+gz$")
$Matches = @($ReleaseAssets.assets | ? name -Match "Windows.+64.+gz$")
if ($Matches.Count -eq 0) {
throw "Could not find a matching nerdctl Windows x64 .gz asset in the latest release."
}
if ($Matches.Count -gt 1) {
throw "Expected exactly one matching nerdctl Windows x64 .gz asset in the latest release, but found $($Matches.Count)."
}
$Release = $Matches[0]

Copilot uses AI. Check for mistakes.
$URL = "https://github.com/microsoft/windows-container-networking/releases/download/v$WinCNIVersion/$WinCNIZip"
} else {
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/microsoft/windows-container-networking/releases/latest"
$Release = ($ReleaseAssets.assets | ? name -Match "Windows.+64.+zip$")
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filter is likely to match multiple zip assets over time (different variants/builds). If it returns more than one result, $URL and $WinCNIZip become arrays and downstream steps will fail. Select a single asset deterministically (or match the exact expected WinCNI asset name) and handle the empty result case.

Suggested change
$Release = ($ReleaseAssets.assets | ? name -Match "Windows.+64.+zip$")
$MatchingAssets = @(
$ReleaseAssets.assets |
? name -Match "^windows-container-networking-cni-amd64-v.+\.zip$" |
Sort-Object -Property Name
)
if ($MatchingAssets.Count -eq 0) {
throw "Unable to find a WinCNI release asset matching 'windows-container-networking-cni-amd64-v*.zip' in the latest release."
}
$Release = $MatchingAssets | Select-Object -First 1

Copilot uses AI. Check for mistakes.
$ContainerdZip = "containerd-$ContainerDVersion-windows-amd64.tar.gz"
$URL = "https://github.com/containerd/containerd/releases/download/v$ContainerDVersion/$ContainerdZip"
} else {
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/containerd/containerd/releases/latest"
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on unauthenticated GitHub API calls makes the script vulnerable to rate limiting (especially in CI or shared NAT environments). Consider supporting an optional GITHUB_TOKEN (Authorization header) or documenting the rate-limit behavior and adding retries/backoff so installs don’t fail intermittently.

Copilot uses AI. Check for mistakes.
$NerdCTLZip = "nerdctl-$NerdCTLVersion-windows-amd64.tar.gz"
$URL = "https://github.com/containerd/nerdctl/releases/download/v$NerdCTLVersion/$NerdCTLZip"
} else {
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/containerd/nerdctl/releases/latest"
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on unauthenticated GitHub API calls makes the script vulnerable to rate limiting (especially in CI or shared NAT environments). Consider supporting an optional GITHUB_TOKEN (Authorization header) or documenting the rate-limit behavior and adding retries/backoff so installs don’t fail intermittently.

Copilot uses AI. Check for mistakes.
$WinCNIZip = "windows-container-networking-cni-amd64-v$WinCNIVersion.zip"
$URL = "https://github.com/microsoft/windows-container-networking/releases/download/v$WinCNIVersion/$WinCNIZip"
} else {
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/microsoft/windows-container-networking/releases/latest"
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on unauthenticated GitHub API calls makes the script vulnerable to rate limiting (especially in CI or shared NAT environments). Consider supporting an optional GITHUB_TOKEN (Authorization header) or documenting the rate-limit behavior and adding retries/backoff so installs don’t fail intermittently.

Copilot uses AI. Check for mistakes.
Comment on lines +573 to +582

if ($ContainerdVersion) {
$ContainerdZip = "containerd-$ContainerDVersion-windows-amd64.tar.gz"
$URL = "https://github.com/containerd/containerd/releases/download/v$ContainerDVersion/$ContainerdZip"
} else {
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/containerd/containerd/releases/latest"
$Release = ($ReleaseAssets.assets | ? name -Match "Windows.+64.+gz$")
$URL = $Release.browser_download_url
$ContainerdZip = $Release.Name
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'pinned version vs latest release' logic is duplicated three times with only repo/regex/filename differences. Consider extracting a small helper (e.g., 'resolve release asset URL + filename') to reduce repetition and ensure any future fixes (like deterministic asset selection and error handling) are applied consistently.

Suggested change
if ($ContainerdVersion) {
$ContainerdZip = "containerd-$ContainerDVersion-windows-amd64.tar.gz"
$URL = "https://github.com/containerd/containerd/releases/download/v$ContainerDVersion/$ContainerdZip"
} else {
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/containerd/containerd/releases/latest"
$Release = ($ReleaseAssets.assets | ? name -Match "Windows.+64.+gz$")
$URL = $Release.browser_download_url
$ContainerdZip = $Release.Name
}
function Resolve-GitHubReleaseAsset {
param(
[string]
$Repository,
[string]
$Version,
[string]
$PinnedAssetName,
[string]
$LatestAssetPattern
)
if ($Version) {
return @{
Url = "https://github.com/$Repository/releases/download/v$Version/$PinnedAssetName"
Name = $PinnedAssetName
}
}
$ReleaseAssets = Invoke-RestMethod "https://api.github.com/repos/$Repository/releases/latest"
$Release = $ReleaseAssets.assets | Where-Object name -Match $LatestAssetPattern | Select-Object -First 1
return @{
Url = $Release.browser_download_url
Name = $Release.Name
}
}
$ContainerdRelease = Resolve-GitHubReleaseAsset `
-Repository "containerd/containerd" `
-Version $ContainerdVersion `
-PinnedAssetName "containerd-$ContainerDVersion-windows-amd64.tar.gz" `
-LatestAssetPattern "Windows.+64.+gz$"
$URL = $ContainerdRelease.Url
$ContainerdZip = $ContainerdRelease.Name

Copilot uses AI. Check for mistakes.
#Download and extract nerdctl binaries
$NerdCTLZip = "nerdctl-$NerdCTLVersion-windows-amd64.tar.gz"
Copy-File "https://github.com/containerd/nerdctl/releases/download/v$NerdCTLVersion/$NerdCTLZip" "$NerdCTLPath\$NerdCTLZip"
if ($NerdCTLVersion) {
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'pinned version vs latest release' logic is duplicated three times with only repo/regex/filename differences. Consider extracting a small helper (e.g., 'resolve release asset URL + filename') to reduce repetition and ensure any future fixes (like deterministic asset selection and error handling) are applied consistently.

Copilot uses AI. Check for mistakes.
$WinCNIZip = "windows-container-networking-cni-amd64-v$WinCNIVersion.zip"
Copy-File "https://github.com/microsoft/windows-container-networking/releases/download/v$WinCNIVersion/$WinCNIZip" "$WinCNIPath\$WinCNIZip"
#Download and extract cni binaries
if ($WinCNIVersion) {
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'pinned version vs latest release' logic is duplicated three times with only repo/regex/filename differences. Consider extracting a small helper (e.g., 'resolve release asset URL + filename') to reduce repetition and ensure any future fixes (like deterministic asset selection and error handling) are applied consistently.

Copilot uses AI. Check for mistakes.
@chaitanya51906312
Copy link
Copy Markdown
Collaborator

I tested the PR that enables automatic retrieval of the latest release versions via the GitHub API instead of hardcoding them and confirmed that the system installs the latest containerd version successfully.

Copy link
Copy Markdown
Collaborator

@chaitanya51906312 chaitanya51906312 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the PR that enables automatic retrieval of the latest release versions via the GitHub API instead of hardcoding them and confirmed that the system installs the latest containerd version successfully.

@sureshbabu-msft sureshbabu-msft requested review from sureshbabu-msft and removed request for sureshbabu-msft April 16, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants