Merge pull request #104317 from ibabou/add_termination_hook_startup_script

Add termination hook to the startup script - GCE Windows
This commit is contained in:
Kubernetes Prow Robot 2021-08-12 17:50:57 -07:00 committed by GitHub
commit f466d9278f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -205,5 +205,8 @@ catch {
Write-Host 'Exception caught in script:'
Write-Host $_.InvocationInfo.PositionMessage
Write-Host "Kubernetes Windows node setup failed: $($_.Exception.Message)"
# Make sure kubelet won't remain running in case any failure happened during the startup.
Write-Host "Cleaning up, Unregistering WorkerServices..."
Unregister-WorkerServices
exit 1
}

View File

@ -1286,6 +1286,12 @@ function Start-WorkerServices {
Log-Output "Kubernetes components started successfully"
}
# Stop and unregister both kubelet & kube-proxy services.
function Unregister-WorkerServices {
& sc.exe delete kube-proxy
& sc.exe delete kubelet
}
# Wait for kubelet and kube-proxy to be ready within 10s.
function WaitFor_KubeletAndKubeProxyReady {
$waited = 0