Merge pull request #79447 from almos98/start-stackdriver-workaround

Wait for StackdriverLogging service to stop before restarting it.
This commit is contained in:
Kubernetes Prow Robot 2019-07-12 14:11:06 -07:00 committed by GitHub
commit 5be1efe9bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1112,13 +1112,39 @@ $STACKDRIVER_ROOT = 'C:\Program Files (x86)\Stackdriver'
# sometimes is unstoppable, so we work around it by killing the processes. # sometimes is unstoppable, so we work around it by killing the processes.
function Restart-StackdriverLoggingAgent { function Restart-StackdriverLoggingAgent {
Stop-Service -NoWait -ErrorAction Ignore StackdriverLogging Stop-Service -NoWait -ErrorAction Ignore StackdriverLogging
# TODO: check periodically to lower the wait time
Start-Sleep 10 # Wait (if necessary) for service to stop.
$timeout = 10
$stopped = (Get-service StackdriverLogging).Status -eq 'Stopped'
for ($i = 0; $i -lt $timeout -and !($stopped); $i++) {
Start-Sleep 1
$stopped = (Get-service StackdriverLogging).Status -eq 'Stopped'
}
if ((Get-service StackdriverLogging).Status -ne 'Stopped') { if ((Get-service StackdriverLogging).Status -ne 'Stopped') {
# Force kill the processes. # Force kill the processes.
Stop-Process -Force -PassThru -Id (Get-WmiObject win32_process | Stop-Process -Force -PassThru -Id (Get-WmiObject win32_process |
Where CommandLine -Like '*Stackdriver/logging*').ProcessId Where CommandLine -Like '*Stackdriver/logging*').ProcessId
# Wait until process has stopped.
$waited = 0
$log_period = 10
$timeout = 60
while ((Get-service StackdriverLogging).Status -ne 'Stopped' -and $waited -lt $timeout) {
Start-Sleep 1
$waited++
if ($waited % $log_period -eq 0) {
Log-Output "Waiting for StackdriverLogging service to stop"
}
}
# Timeout occurred
if ($waited -ge $timeout) {
Throw ("Timeout while waiting for StackdriverLogging service to stop")
}
} }
Start-Service StackdriverLogging Start-Service StackdriverLogging
} }