Skip to content

Commit 37deed5

Browse files
authored
feat: windows base version update & script to do it manually (#8315)
1 parent b43569a commit 37deed5

6 files changed

Lines changed: 119 additions & 9 deletions

File tree

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ coverage:
257257
unit-tests:
258258
$(GO) test `go list ./... | grep -v e2e` -coverprofile coverage_raw.out -covermode count
259259

260+
.PHONY: update-windows-base-versions
261+
update-windows-base-versions:
262+
./vhdbuilder/packer/windows/update_windows_base_versions.sh
263+
260264
.PHONY: validate-components
261265
validate-components:
262266
@./hack/tools/bin/cue vet -c ./schemas/components.cue ./parts/common/components.json

e2e/config/vhd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ func (i *Image) String() string {
302302
return fmt.Sprintf("%s %s %s %s", i.OS, i.Name, i.Version, i.Arch)
303303
}
304304

305+
func (i *Image) SupportsScriptless() bool {
306+
return !i.Flatcar && !i.Distro.IsWindowsDistro()
307+
}
308+
305309
func GetVHDResourceID(ctx context.Context, i Image, location string) (VHDResourceID, error) {
306310
switch {
307311
case i.Version != "":

e2e/validators.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,15 +2018,15 @@ func ValidateNodeHasLabel(ctx context.Context, s *Scenario, labelKey, expectedVa
20182018
// ValidateScriptlessCSECmd checks if the node has scriptless cmd correctly enabled
20192019
func ValidateScriptlessCSECmd(ctx context.Context, s *Scenario) {
20202020
nbc := s.Runtime.NBC
2021-
if nbc != nil && nbc.EnableScriptlessCSECmd && !s.VHD.Flatcar && !s.VHD.Distro.IsWindowsDistro() {
2021+
if nbc != nil && nbc.EnableScriptlessCSECmd && s.VHD.SupportsScriptless() {
20222022
ValidateFileExists(ctx, s, "/opt/azure/containers/scriptless-cse-overrides.txt")
20232023
}
20242024
}
20252025

20262026
// ValidateScriptlessNBCCSECmd checks if the node has scriptless NBCCSECmd correctly enabled
20272027
func ValidateScriptlessNBCCSECmd(ctx context.Context, s *Scenario) {
20282028
nbc := s.Runtime.NBC
2029-
if nbc != nil && nbc.EnableScriptlessNBCCSECmd && !s.VHD.Flatcar {
2029+
if nbc != nil && nbc.EnableScriptlessNBCCSECmd && s.VHD.SupportsScriptless() {
20302030
fileNameToCheck := "/opt/azure/containers/aks-node-controller-nbc-cmd.sh"
20312031
if !config.Config.DisableScriptLessCompilation && !s.Tags.NetworkIsolated {
20322032
fileNameToCheck = "/opt/azure/containers/aks-node-controller-nbc-cmd-hack.sh"

e2e/vmss.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func createVMSSModel(ctx context.Context, s *Scenario) armcompute.VirtualMachine
341341
customData, err = injectWriteFilesEntriesToCustomData(customData, s.Config.CustomDataWriteFiles)
342342
require.NoError(s.T, err, "failed to inject customData write_files entries")
343343
}
344-
if s.Runtime.NBC.EnableScriptlessCSECmd && !s.VHD.Flatcar && !s.VHD.Distro.IsWindowsDistro() {
344+
if s.Runtime.NBC.EnableScriptlessCSECmd && s.VHD.SupportsScriptless() {
345345
// Validate that the custom data doesn't contain any script content,
346346
// which indicates that the scriptless CSE is working as intended
347347
decodedCustomData, err := base64.StdEncoding.DecodeString(customData)
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Updates base_image_version in windows_settings.json to the latest available
5+
# version from the Azure Marketplace for each Windows SKU.
6+
#
7+
# This script is a backup. In an ideal world, use the pipeline https://dev.azure.com/msazure/CloudNativeCompute/_build/results?buildId=160464184&view=results
8+
# and only run this script manually if the pipeline fails to update the versions or if you want to check for updates without modifying the settings file (using --dry-run).
9+
#
10+
# Prerequisites:
11+
# - az CLI installed and logged in
12+
# - jq installed
13+
#
14+
# Usage:
15+
# ./update_windows_base_versions.sh [--dry-run]
16+
17+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18+
SETTINGS_FILE="${SCRIPT_DIR}/windows_settings.json"
19+
DEFAULT_PUBLISHER="MicrosoftWindowsServer"
20+
DEFAULT_OFFER="MicrosoftWindowsServer"
21+
DRY_RUN=false
22+
23+
if [ "${1:-}" = "--dry-run" ]; then
24+
DRY_RUN=true
25+
fi
26+
27+
if [ ! -f "${SETTINGS_FILE}" ]; then
28+
echo "ERROR: ${SETTINGS_FILE} not found"
29+
exit 1
30+
fi
31+
32+
for cmd in az jq; do
33+
if ! command -v "${cmd}" &>/dev/null; then
34+
echo "ERROR: ${cmd} is required but not installed"
35+
exit 1
36+
fi
37+
done
38+
39+
# Build a list of unique (publisher, sku) pairs to query.
40+
# Multiple JSON keys can share the same SKU prefix (e.g. 2025 and 2025-gen2
41+
# have different SKUs but should resolve to the same base_image_version).
42+
# We query each unique SKU individually.
43+
mapfile -t sku_keys < <(jq -r '.WindowsBaseVersions | keys[]' "${SETTINGS_FILE}")
44+
45+
updated=0
46+
errors=0
47+
48+
for key in "${sku_keys[@]}"; do
49+
sku=$(jq -r ".WindowsBaseVersions.\"${key}\".base_image_sku" "${SETTINGS_FILE}")
50+
offer=$(jq -r ".WindowsBaseVersions.\"${key}\".base_image_offer // \"${DEFAULT_OFFER}\"" "${SETTINGS_FILE}")
51+
publisher=$(jq -r ".WindowsBaseVersions.\"${key}\".base_image_publisher // \"${DEFAULT_PUBLISHER}\"" "${SETTINGS_FILE}")
52+
current_version=$(jq -r ".WindowsBaseVersions.\"${key}\".base_image_version" "${SETTINGS_FILE}")
53+
54+
echo "Querying latest version for ${key} (publisher=${publisher}, offer=${offer}, sku=${sku})..."
55+
56+
latest_version=$(
57+
az vm image list \
58+
-p "${publisher}" \
59+
-f "${offer}" \
60+
-s "${sku}" \
61+
--all \
62+
--query "[].version" \
63+
-o tsv 2>/dev/null |
64+
sort -uV |
65+
tail -n 1
66+
) || true
67+
68+
if [ -z "${latest_version}" ]; then
69+
echo " WARNING: no versions found for sku=${sku}, skipping"
70+
errors=$((errors + 1))
71+
continue
72+
fi
73+
74+
if [ "${current_version}" = "${latest_version}" ]; then
75+
echo " ${key}: already up to date (${current_version})"
76+
continue
77+
fi
78+
79+
echo " ${key}: ${current_version} -> ${latest_version}"
80+
81+
if [ "${DRY_RUN}" = "false" ]; then
82+
tmp=$(mktemp)
83+
jq ".WindowsBaseVersions.\"${key}\".base_image_version = \"${latest_version}\"" \
84+
"${SETTINGS_FILE}" >"${tmp}" &&
85+
mv "${tmp}" "${SETTINGS_FILE}"
86+
updated=$((updated + 1))
87+
else
88+
updated=$((updated + 1))
89+
fi
90+
done
91+
92+
echo ""
93+
if [ "${DRY_RUN}" = "true" ]; then
94+
echo "Dry run complete. ${updated} version(s) would be updated, ${errors} error(s)."
95+
else
96+
echo "Done. ${updated} version(s) updated, ${errors} error(s)."
97+
fi
98+
99+
if [ "${errors}" -gt 0 ]; then
100+
exit 1
101+
fi
102+

vhdbuilder/packer/windows/windows_settings.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"base_image_offer": "windowsserver2022",
2020
"base_image_sku": "2022-Datacenter-Core-smalldisk",
2121
"windows_image_name": "windows-2022-containerd",
22-
"base_image_version": "20348.4893.260303",
22+
"base_image_version": "20348.5020.260413",
2323
"patches_to_apply": []
2424
},
2525
"2022-containerd-gen2": {
@@ -28,35 +28,35 @@
2828
"base_image_offer": "windowsserver2022",
2929
"base_image_sku": "2022-datacenter-core-smalldisk-g2",
3030
"windows_image_name": "windows-2022-containerd",
31-
"base_image_version": "20348.4893.260303",
31+
"base_image_version": "20348.5020.260413",
3232
"patches_to_apply": []
3333
},
3434
"2025": {
3535
"os_disk_size": "45",
3636
"base_image_sku": "2025-datacenter-core-smalldisk",
3737
"windows_image_name": "windows-2025",
38-
"base_image_version": "26100.32522.260306",
38+
"base_image_version": "26100.32690.260413",
3939
"patches_to_apply": []
4040
},
4141
"2025-gen2": {
4242
"os_disk_size": "45",
4343
"base_image_sku": "2025-datacenter-core-smalldisk-g2",
4444
"windows_image_name": "windows-2025",
45-
"base_image_version": "26100.32522.260306",
45+
"base_image_version": "26100.32690.260413",
4646
"patches_to_apply": []
4747
},
4848
"23H2": {
4949
"os_disk_size": "35",
5050
"base_image_sku": "23h2-datacenter-core",
5151
"windows_image_name": "windows-23H2",
52-
"base_image_version": "25398.2207.260303",
52+
"base_image_version": "25398.2274.260411",
5353
"patches_to_apply": []
5454
},
5555
"23H2-gen2": {
5656
"os_disk_size": "35",
5757
"base_image_sku": "23h2-datacenter-core-g2",
5858
"windows_image_name": "windows-23H2",
59-
"base_image_version": "25398.2207.260303",
59+
"base_image_version": "25398.2274.260411",
6060
"patches_to_apply": []
6161
}
6262
},

0 commit comments

Comments
 (0)