From 131ddaeb5600e3844e97602765698ff6f951e52a Mon Sep 17 00:00:00 2001 From: Ben Moss Date: Tue, 10 Dec 2019 11:46:49 -0500 Subject: [PATCH] Remove docker service when draining This is necessary because the service is not managed by BOSH as a regular ctl script, but instead it's installed in the pre-start. --- jobs/docker-windows/templates/drain.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jobs/docker-windows/templates/drain.ps1 b/jobs/docker-windows/templates/drain.ps1 index 673a6a5..1505eba 100644 --- a/jobs/docker-windows/templates/drain.ps1 +++ b/jobs/docker-windows/templates/drain.ps1 @@ -1,7 +1,7 @@ $ErrorActionPreference = "Stop"; echo "Querying docker service" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log" -$docker=(Get-Service | where { $_.Name -eq 'docker' }) +$docker = Get-WmiObject -Class Win32_Service -Filter "Name='docker'" if ($docker -eq $null) { echo "Docker service not found; Exiting 0" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log" "0" @@ -9,10 +9,11 @@ if ($docker -eq $null) { } echo "Docker service found" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log" -If ($docker.Status -Eq "Running") { +If ($docker.State -Eq "Running") { echo "Docker service running; Stopping" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log" - Stop-Service $docker | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log" + $docker.StopService() | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log" } +$service.Delete() echo "Docker service drained; Exit 0" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log" "0"