Skip to content

Commit f5a1abc

Browse files
authored
Fix windows network configuration for VHD caching feature (#7313)
1 parent c4ddd55 commit f5a1abc

File tree

21 files changed

+855
-845
lines changed

21 files changed

+855
-845
lines changed

e2e/scenario_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,14 +2195,18 @@ func Test_Ubuntu2404_VHDCaching(t *testing.T) {
21952195
RunScenario(t, &Scenario{
21962196
Description: "T",
21972197
Config: Config{
2198-
Cluster: ClusterKubenet,
2199-
VHD: config.VHDUbuntu2204Gen2Containerd,
2200-
VHDCaching: true,
2201-
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
2202-
},
2198+
Cluster: ClusterKubenet,
2199+
VHD: config.VHDUbuntu2204Gen2Containerd,
2200+
VHDCaching: true,
2201+
BootstrapConfigMutator: EmptyBootstrapConfigMutator,
22032202
Validator: func(ctx context.Context, s *Scenario) {
22042203
},
22052204
VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
2205+
// If the VHD has incorrect settings (like network misconfiguration)
2206+
// deploying more than one VM may expose the issue.
2207+
// This check is not always reliable, since only one VM is created per test run in the current framework.
2208+
// Therefore, tests may incorrectly pass more often than they fail in these cases.
2209+
vmss.SKU.Capacity = to.Ptr[int64](2)
22062210
},
22072211
},
22082212
})

e2e/scenario_win_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,16 @@ func Test_Windows2022_VHDCaching(t *testing.T) {
346346
RunScenario(t, &Scenario{
347347
Description: "VHD Caching",
348348
Config: Config{
349-
Cluster: ClusterAzureNetwork,
350-
VHD: config.VHDWindows2022Containerd, // gen1 is default for windows 2022
351-
VHDCaching: true,
352-
VMConfigMutator: EmptyVMConfigMutator,
349+
Cluster: ClusterAzureNetwork,
350+
VHD: config.VHDWindows2022Containerd, // gen1 is default for windows 2022
351+
VHDCaching: true,
352+
VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
353+
// If the VHD has incorrect settings (like network misconfiguration)
354+
// deploying more than one VM may expose the issue.
355+
// This check is not always reliable, since only one VM is created per test run in the current framework.
356+
// Therefore, tests may incorrectly pass more often than they fail in these cases.
357+
vmss.SKU.Capacity = to.Ptr[int64](2)
358+
},
353359
BootstrapConfigMutator: EmptyBootstrapConfigMutator,
354360
Validator: func(ctx context.Context, s *Scenario) {
355361
ValidateWindowsVersionFromWindowsSettings(ctx, s, "2022-containerd")

parts/windows/kuberneteswindowssetup.ps1

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,50 @@ function BasePrep {
417417
New-HostsConfigService
418418
}
419419

420+
Set-Explorer
421+
Adjust-PageFileSize
422+
Logs-To-Event -TaskName "AKS.WindowsCSE.PreprovisionExtension" -TaskMessage "Start preProvisioning script"
423+
PREPROVISION_EXTENSION
424+
Update-ServiceFailureActions
425+
Adjust-DynamicPortRange
426+
Register-LogsCleanupScriptTask
427+
Register-NodeResetScriptTask
428+
429+
Update-DefenderPreferences
430+
431+
$windowsVersion = Get-WindowsVersion
432+
if ($windowsVersion -ne "1809") {
433+
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Skip secure TLS protocols for Windows version: $windowsVersion"
434+
} else {
435+
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Start to enable secure TLS protocols"
436+
try {
437+
. C:\k\windowssecuretls.ps1
438+
Enable-SecureTls
439+
}
440+
catch {
441+
Set-ExitCode -ExitCode $global:WINDOWS_CSE_ERROR_ENABLE_SECURE_TLS -ErrorMessage $_
442+
}
443+
}
444+
445+
Enable-FIPSMode -FipsEnabled $fipsEnabled
446+
if ($global:WindowsGmsaPackageUrl) {
447+
Install-GmsaPlugin -GmsaPackageUrl $global:WindowsGmsaPackageUrl
448+
}
449+
450+
Write-Log "BasePrep completed successfully"
451+
Logs-To-Event -TaskName "AKS.WindowsCSE.BasePrep" -TaskMessage "BasePrep completed successfully"
452+
}
453+
454+
# ====== NODE PREP: CLUSTER INTEGRATION ======
455+
# All operations that should only run when connecting to the actual cluster
456+
function NodePrep {
457+
Install-KubernetesServices -KubeDir $global:KubeDir
458+
459+
Write-Log "Starting NodePrep - Cluster integration"
460+
Logs-To-Event -TaskName "AKS.WindowsCSE.NodePrep" -TaskMessage "Starting NodePrep - Cluster integration"
461+
462+
Check-APIServerConnectivity -MasterIP $MasterIP
463+
420464
Write-Log "Configuring networking with NetworkPlugin:$global:NetworkPlugin"
421465

422466
# Configure network policy.
@@ -464,50 +508,6 @@ function BasePrep {
464508
Write-Log "Enable-WindowsCiliumNetworking is not a recognized function, will skip Windows Cilium Networking installation"
465509
}
466510

467-
Set-Explorer
468-
Adjust-PageFileSize
469-
Logs-To-Event -TaskName "AKS.WindowsCSE.PreprovisionExtension" -TaskMessage "Start preProvisioning script"
470-
PREPROVISION_EXTENSION
471-
Update-ServiceFailureActions
472-
Adjust-DynamicPortRange
473-
Register-LogsCleanupScriptTask
474-
Register-NodeResetScriptTask
475-
476-
Update-DefenderPreferences
477-
478-
$windowsVersion = Get-WindowsVersion
479-
if ($windowsVersion -ne "1809") {
480-
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Skip secure TLS protocols for Windows version: $windowsVersion"
481-
} else {
482-
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Start to enable secure TLS protocols"
483-
try {
484-
. C:\k\windowssecuretls.ps1
485-
Enable-SecureTls
486-
}
487-
catch {
488-
Set-ExitCode -ExitCode $global:WINDOWS_CSE_ERROR_ENABLE_SECURE_TLS -ErrorMessage $_
489-
}
490-
}
491-
492-
Enable-FIPSMode -FipsEnabled $fipsEnabled
493-
if ($global:WindowsGmsaPackageUrl) {
494-
Install-GmsaPlugin -GmsaPackageUrl $global:WindowsGmsaPackageUrl
495-
}
496-
497-
Write-Log "BasePrep completed successfully"
498-
Logs-To-Event -TaskName "AKS.WindowsCSE.BasePrep" -TaskMessage "BasePrep completed successfully"
499-
}
500-
501-
# ====== NODE PREP: CLUSTER INTEGRATION ======
502-
# All operations that should only run when connecting to the actual cluster
503-
function NodePrep {
504-
Install-KubernetesServices -KubeDir $global:KubeDir
505-
506-
Write-Log "Starting NodePrep - Cluster integration"
507-
Logs-To-Event -TaskName "AKS.WindowsCSE.NodePrep" -TaskMessage "Starting NodePrep - Cluster integration"
508-
509-
Check-APIServerConnectivity -MasterIP $MasterIP
510-
511511
if ($global:WindowsCalicoPackageURL) {
512512
Start-InstallCalico -RootDir "c:\" -KubeServiceCIDR $global:KubeServiceCIDR -KubeDnsServiceIp $KubeDnsServiceIp
513513
}

pkg/agent/testdata/AKSWindows2019+CustomCloud+ootcredentialprovider/CustomData

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,50 @@ function BasePrep {
411411
New-HostsConfigService
412412
}
413413

414+
Set-Explorer
415+
Adjust-PageFileSize
416+
Logs-To-Event -TaskName "AKS.WindowsCSE.PreprovisionExtension" -TaskMessage "Start preProvisioning script"
417+
418+
Update-ServiceFailureActions
419+
Adjust-DynamicPortRange
420+
Register-LogsCleanupScriptTask
421+
Register-NodeResetScriptTask
422+
423+
Update-DefenderPreferences
424+
425+
$windowsVersion = Get-WindowsVersion
426+
if ($windowsVersion -ne "1809") {
427+
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Skip secure TLS protocols for Windows version: $windowsVersion"
428+
} else {
429+
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Start to enable secure TLS protocols"
430+
try {
431+
. C:\k\windowssecuretls.ps1
432+
Enable-SecureTls
433+
}
434+
catch {
435+
Set-ExitCode -ExitCode $global:WINDOWS_CSE_ERROR_ENABLE_SECURE_TLS -ErrorMessage $_
436+
}
437+
}
438+
439+
Enable-FIPSMode -FipsEnabled $fipsEnabled
440+
if ($global:WindowsGmsaPackageUrl) {
441+
Install-GmsaPlugin -GmsaPackageUrl $global:WindowsGmsaPackageUrl
442+
}
443+
444+
Write-Log "BasePrep completed successfully"
445+
Logs-To-Event -TaskName "AKS.WindowsCSE.BasePrep" -TaskMessage "BasePrep completed successfully"
446+
}
447+
448+
# ====== NODE PREP: CLUSTER INTEGRATION ======
449+
# All operations that should only run when connecting to the actual cluster
450+
function NodePrep {
451+
Install-KubernetesServices -KubeDir $global:KubeDir
452+
453+
Write-Log "Starting NodePrep - Cluster integration"
454+
Logs-To-Event -TaskName "AKS.WindowsCSE.NodePrep" -TaskMessage "Starting NodePrep - Cluster integration"
455+
456+
Check-APIServerConnectivity -MasterIP $MasterIP
457+
414458
Write-Log "Configuring networking with NetworkPlugin:$global:NetworkPlugin"
415459

416460
# Configure network policy.
@@ -458,50 +502,6 @@ function BasePrep {
458502
Write-Log "Enable-WindowsCiliumNetworking is not a recognized function, will skip Windows Cilium Networking installation"
459503
}
460504

461-
Set-Explorer
462-
Adjust-PageFileSize
463-
Logs-To-Event -TaskName "AKS.WindowsCSE.PreprovisionExtension" -TaskMessage "Start preProvisioning script"
464-
465-
Update-ServiceFailureActions
466-
Adjust-DynamicPortRange
467-
Register-LogsCleanupScriptTask
468-
Register-NodeResetScriptTask
469-
470-
Update-DefenderPreferences
471-
472-
$windowsVersion = Get-WindowsVersion
473-
if ($windowsVersion -ne "1809") {
474-
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Skip secure TLS protocols for Windows version: $windowsVersion"
475-
} else {
476-
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Start to enable secure TLS protocols"
477-
try {
478-
. C:\k\windowssecuretls.ps1
479-
Enable-SecureTls
480-
}
481-
catch {
482-
Set-ExitCode -ExitCode $global:WINDOWS_CSE_ERROR_ENABLE_SECURE_TLS -ErrorMessage $_
483-
}
484-
}
485-
486-
Enable-FIPSMode -FipsEnabled $fipsEnabled
487-
if ($global:WindowsGmsaPackageUrl) {
488-
Install-GmsaPlugin -GmsaPackageUrl $global:WindowsGmsaPackageUrl
489-
}
490-
491-
Write-Log "BasePrep completed successfully"
492-
Logs-To-Event -TaskName "AKS.WindowsCSE.BasePrep" -TaskMessage "BasePrep completed successfully"
493-
}
494-
495-
# ====== NODE PREP: CLUSTER INTEGRATION ======
496-
# All operations that should only run when connecting to the actual cluster
497-
function NodePrep {
498-
Install-KubernetesServices -KubeDir $global:KubeDir
499-
500-
Write-Log "Starting NodePrep - Cluster integration"
501-
Logs-To-Event -TaskName "AKS.WindowsCSE.NodePrep" -TaskMessage "Starting NodePrep - Cluster integration"
502-
503-
Check-APIServerConnectivity -MasterIP $MasterIP
504-
505505
if ($global:WindowsCalicoPackageURL) {
506506
Start-InstallCalico -RootDir "c:\" -KubeServiceCIDR $global:KubeServiceCIDR -KubeDnsServiceIp $KubeDnsServiceIp
507507
}

pkg/agent/testdata/AKSWindows2019+CustomCloud/CustomData

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,50 @@ function BasePrep {
411411
New-HostsConfigService
412412
}
413413

414+
Set-Explorer
415+
Adjust-PageFileSize
416+
Logs-To-Event -TaskName "AKS.WindowsCSE.PreprovisionExtension" -TaskMessage "Start preProvisioning script"
417+
418+
Update-ServiceFailureActions
419+
Adjust-DynamicPortRange
420+
Register-LogsCleanupScriptTask
421+
Register-NodeResetScriptTask
422+
423+
Update-DefenderPreferences
424+
425+
$windowsVersion = Get-WindowsVersion
426+
if ($windowsVersion -ne "1809") {
427+
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Skip secure TLS protocols for Windows version: $windowsVersion"
428+
} else {
429+
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Start to enable secure TLS protocols"
430+
try {
431+
. C:\k\windowssecuretls.ps1
432+
Enable-SecureTls
433+
}
434+
catch {
435+
Set-ExitCode -ExitCode $global:WINDOWS_CSE_ERROR_ENABLE_SECURE_TLS -ErrorMessage $_
436+
}
437+
}
438+
439+
Enable-FIPSMode -FipsEnabled $fipsEnabled
440+
if ($global:WindowsGmsaPackageUrl) {
441+
Install-GmsaPlugin -GmsaPackageUrl $global:WindowsGmsaPackageUrl
442+
}
443+
444+
Write-Log "BasePrep completed successfully"
445+
Logs-To-Event -TaskName "AKS.WindowsCSE.BasePrep" -TaskMessage "BasePrep completed successfully"
446+
}
447+
448+
# ====== NODE PREP: CLUSTER INTEGRATION ======
449+
# All operations that should only run when connecting to the actual cluster
450+
function NodePrep {
451+
Install-KubernetesServices -KubeDir $global:KubeDir
452+
453+
Write-Log "Starting NodePrep - Cluster integration"
454+
Logs-To-Event -TaskName "AKS.WindowsCSE.NodePrep" -TaskMessage "Starting NodePrep - Cluster integration"
455+
456+
Check-APIServerConnectivity -MasterIP $MasterIP
457+
414458
Write-Log "Configuring networking with NetworkPlugin:$global:NetworkPlugin"
415459

416460
# Configure network policy.
@@ -458,50 +502,6 @@ function BasePrep {
458502
Write-Log "Enable-WindowsCiliumNetworking is not a recognized function, will skip Windows Cilium Networking installation"
459503
}
460504

461-
Set-Explorer
462-
Adjust-PageFileSize
463-
Logs-To-Event -TaskName "AKS.WindowsCSE.PreprovisionExtension" -TaskMessage "Start preProvisioning script"
464-
465-
Update-ServiceFailureActions
466-
Adjust-DynamicPortRange
467-
Register-LogsCleanupScriptTask
468-
Register-NodeResetScriptTask
469-
470-
Update-DefenderPreferences
471-
472-
$windowsVersion = Get-WindowsVersion
473-
if ($windowsVersion -ne "1809") {
474-
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Skip secure TLS protocols for Windows version: $windowsVersion"
475-
} else {
476-
Logs-To-Event -TaskName "AKS.WindowsCSE.EnableSecureTLS" -TaskMessage "Start to enable secure TLS protocols"
477-
try {
478-
. C:\k\windowssecuretls.ps1
479-
Enable-SecureTls
480-
}
481-
catch {
482-
Set-ExitCode -ExitCode $global:WINDOWS_CSE_ERROR_ENABLE_SECURE_TLS -ErrorMessage $_
483-
}
484-
}
485-
486-
Enable-FIPSMode -FipsEnabled $fipsEnabled
487-
if ($global:WindowsGmsaPackageUrl) {
488-
Install-GmsaPlugin -GmsaPackageUrl $global:WindowsGmsaPackageUrl
489-
}
490-
491-
Write-Log "BasePrep completed successfully"
492-
Logs-To-Event -TaskName "AKS.WindowsCSE.BasePrep" -TaskMessage "BasePrep completed successfully"
493-
}
494-
495-
# ====== NODE PREP: CLUSTER INTEGRATION ======
496-
# All operations that should only run when connecting to the actual cluster
497-
function NodePrep {
498-
Install-KubernetesServices -KubeDir $global:KubeDir
499-
500-
Write-Log "Starting NodePrep - Cluster integration"
501-
Logs-To-Event -TaskName "AKS.WindowsCSE.NodePrep" -TaskMessage "Starting NodePrep - Cluster integration"
502-
503-
Check-APIServerConnectivity -MasterIP $MasterIP
504-
505505
if ($global:WindowsCalicoPackageURL) {
506506
Start-InstallCalico -RootDir "c:\" -KubeServiceCIDR $global:KubeServiceCIDR -KubeDnsServiceIp $KubeDnsServiceIp
507507
}

0 commit comments

Comments
 (0)