Skip to content

Commit 9ab4d52

Browse files
author
Ramkumar Chinchani
committed
feat: enhance CA certificates refresh task registration for legacy CSE packages
1 parent bee6cd6 commit 9ab4d52

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

parts/windows/kuberneteswindowssetup.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,14 @@ function BasePrep {
475475
Adjust-DynamicPortRange
476476
Register-LogsCleanupScriptTask
477477
Register-NodeResetScriptTask
478-
if (Should-InstallCACertificatesRefreshTask -Location $Location) {
478+
# Guard against older CSE packages that do not yet export Should-InstallCACertificatesRefreshTask.
479+
# If the function is absent (old package), fall back to the previous unconditional behaviour so
480+
# that legacy/ussec/usnat clusters continue to register the refresh task.
481+
if (Get-Command -Name Should-InstallCACertificatesRefreshTask -ErrorAction Ignore) {
482+
if (Should-InstallCACertificatesRefreshTask -Location $Location) {
483+
Register-CACertificatesRefreshTask -Location $Location
484+
}
485+
} elseif (Get-Command -Name Register-CACertificatesRefreshTask -ErrorAction Ignore) {
479486
Register-CACertificatesRefreshTask -Location $Location
480487
}
481488

spec/parts/linux/cloud-init/artifacts/init_aks_custom_cloud_spec.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@ Describe 'init-aks-custom-cloud.sh refresh mode wiring'
1818
When run grep -Eq '^location_normalized="\$\{refresh_location,,\}"$' "$script_path"
1919
The status should eq 0
2020

21-
When run grep -Eq 'ussec\*\|usnat\*\) cert_endpoint_mode="legacy"' "$script_path"
21+
When run grep -Eq 'ussec\*|usnat\*\) cert_endpoint_mode="legacy"' "$script_path"
2222
The status should eq 0
2323
End
2424

2525
It 'installs refresh schedule only for legacy mode or opted-in rcv1p mode'
2626
When run grep -Eq '^install_ca_refresh_schedule=0$' "$script_path"
2727
The status should eq 0
2828

29-
When run grep -Eq '^\s*install_ca_refresh_schedule=1$' "$script_path"
29+
When run grep -Eq '^[[:space:]]*install_ca_refresh_schedule=1$' "$script_path"
3030
The status should eq 0
3131

32-
When run grep -Eq '^\s*if \[ "\$install_ca_refresh_schedule" -eq 1 \]; then$' "$script_path"
32+
When run grep -Eq '^[[:space:]]*if \[ "\$install_ca_refresh_schedule" -eq 1 \]; then$' "$script_path"
3333
The status should eq 0
3434
End
3535

3636
It 'exits early in ca-refresh mode after certificate refresh logic'
3737
When run grep -Eq '^if \[ "\$action" = "ca-refresh" \]; then$' "$script_path"
3838
The status should eq 0
3939

40-
When run grep -Eq '^\s*exit$' "$script_path"
40+
When run grep -Eq '^[[:space:]]*exit$' "$script_path"
4141
The status should eq 0
4242
End
4343

4444
It 'passes LOCATION directly into cron refresh command'
45-
When run grep -Eq 'ca-refresh \\\\"\$LOCATION\\\\"' "$script_path"
45+
When run grep -Eq 'ca-refresh \\"\$LOCATION\\"' "$script_path"
4646
The status should eq 0
4747
End
4848

staging/cse/windows/kubernetesfunc.tests.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ Describe 'Register-CACertificatesRefreshTask' {
7474
$script:lastScheduledTaskArgument = $null
7575

7676
Mock Logs-To-Event
77-
Mock Write-Log
7877
Mock New-ScheduledTaskPrincipal -MockWith { return @{ Kind = 'principal' } }
7978
Mock New-JobTrigger -MockWith { return @{ Kind = 'trigger' } }
8079
Mock New-ScheduledTask -MockWith { return @{ Kind = 'definition' } }
@@ -107,7 +106,6 @@ Describe 'Register-CACertificatesRefreshTask' {
107106

108107
Describe 'Should-InstallCACertificatesRefreshTask' {
109108
BeforeEach {
110-
Mock Write-Log
111109
}
112110

113111
It 'returns true for legacy regions without calling the opt-in endpoint' {
@@ -143,7 +141,6 @@ Describe 'Should-InstallCACertificatesRefreshTask' {
143141

144142
Describe 'Get-CACertificates' {
145143
BeforeEach {
146-
Mock Write-Log
147144
Mock Create-Directory -MockWith {
148145
param($FullPath, $DirectoryUsage)
149146
if (-not (Test-Path $FullPath)) {

0 commit comments

Comments
 (0)