keep launcher cleanup from aborting on docker stderr warnings
docker/compose emit warnings on stderr (e.g. nothing to remove), which tripped ErrorActionPreference=Stop and killed the run before the clone. soften the preference around the best-effort cleanup steps.
This commit is contained in:
@@ -61,16 +61,27 @@ function Clear-InterruptedRun {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (Get-Command docker -ErrorAction SilentlyContinue) {
|
if (Get-Command docker -ErrorAction SilentlyContinue) {
|
||||||
# Only try compose down when the engine is actually responding, otherwise
|
# docker/compose write warnings to stderr (e.g. "No resource found to
|
||||||
# skip quietly - a fresh box may not have Docker started yet.
|
# remove"), which would trip $ErrorActionPreference='Stop' and abort the
|
||||||
docker info *> $null
|
# whole run. These cleanup steps are best-effort, so soften the preference
|
||||||
if ($LASTEXITCODE -eq 0) {
|
# and swallow all streams for their duration.
|
||||||
Write-Host "==> Cleaning up any interrupted '$Project' stack" -ForegroundColor Cyan
|
$previous = $ErrorActionPreference
|
||||||
# --remove-orphans clears containers left by a killed build; volumes are
|
$ErrorActionPreference = 'Continue'
|
||||||
# intentionally kept so the DB survives a retry.
|
try {
|
||||||
docker compose -p $Project down --remove-orphans *> $null
|
# Only try compose down when the engine is actually responding, otherwise
|
||||||
# Reclaim only dangling build cache from failed/partial builds.
|
# skip quietly - a fresh box may not have Docker started yet.
|
||||||
docker builder prune -f *> $null
|
docker info *> $null
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Write-Host "==> Cleaning up any interrupted '$Project' stack" -ForegroundColor Cyan
|
||||||
|
# --remove-orphans clears containers left by a killed build; volumes are
|
||||||
|
# intentionally kept so the DB survives a retry.
|
||||||
|
docker compose -p $Project down --remove-orphans *> $null
|
||||||
|
# Reclaim only dangling build cache from failed/partial builds.
|
||||||
|
docker builder prune -f *> $null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
$ErrorActionPreference = $previous
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user