Skip to content

Commit 6a23a62

Browse files
authored
Merge pull request kubernetes#77378 from yujuhong/kill-sd
GCE/Windows: force kill the stackdriver processes when necessary
2 parents 6a8a368 + bee570a commit 6a23a62

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

cluster/gce/windows/k8s-node-setup.psm1

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,22 @@ function Configure-Dockerd {
10791079
$STACKDRIVER_VERSION = 'v1-9'
10801080
$STACKDRIVER_ROOT = 'C:\Program Files (x86)\Stackdriver'
10811081

1082+
1083+
# Restart the Stackdriver logging agent
1084+
# `Restart-Service StackdriverLogging` may fail because StackdriverLogging
1085+
# sometimes is unstoppable, so we work around it by killing the processes.
1086+
function Restart-StackdriverLoggingAgent {
1087+
Stop-Service -NoWait StackdriverLogging
1088+
# TODO: check periodically to lower the wait time
1089+
Start-Sleep 10
1090+
if ((Get-service StackdriverLogging).Status -ne 'Stopped') {
1091+
# Force kill the processes.
1092+
Stop-Process -Force -PassThru -Id (Get-WmiObject win32_process |
1093+
Where CommandLine -Like '*Stackdriver/logging*').ProcessId
1094+
}
1095+
Start-Service StackdriverLogging
1096+
}
1097+
10821098
# Install and start the Stackdriver logging agent according to
10831099
# https://cloud.google.com/logging/docs/agent/installation.
10841100
# TODO(yujuhong): Update to a newer Stackdriver agent once it is released to
@@ -1105,7 +1121,7 @@ function InstallAndStart-LoggingAgent {
11051121
"Stackdriver logging agent is already installed")
11061122
# Restart-Service restarts a running service or starts a not-running
11071123
# service.
1108-
Restart-Service StackdriverLogging
1124+
Restart-StackdriverLoggingAgent
11091125
return
11101126
}
11111127

@@ -1136,7 +1152,7 @@ function InstallAndStart-LoggingAgent {
11361152
-Encoding ASCII
11371153

11381154
# Restart the service to pick up the new configurations.
1139-
Restart-Service StackdriverLogging
1155+
Restart-StackdriverLoggingAgent
11401156
Remove-Item -Force -Recurse $tmp_dir
11411157
}
11421158

0 commit comments

Comments
 (0)