Improve build container cleanup
This commit is contained in:
parent
d021fb6cda
commit
1bb49c37e0
1 changed files with 17 additions and 2 deletions
|
@ -306,9 +306,24 @@ App::post('/v1/runtimes')
|
||||||
Console::error('Build failed: ' . $th->getMessage() . $stdout);
|
Console::error('Build failed: ' . $th->getMessage() . $stdout);
|
||||||
throw new Exception($th->getMessage() . $stdout, 500);
|
throw new Exception($th->getMessage() . $stdout, 500);
|
||||||
} finally {
|
} finally {
|
||||||
if (!empty($containerId) && $remove) {
|
// Container cleanup
|
||||||
$orchestration->remove($containerId, true);
|
if($remove) {
|
||||||
|
if (!empty($containerId)) {
|
||||||
|
// If container properly created
|
||||||
|
$orchestration->remove($containerId, true);
|
||||||
|
} else {
|
||||||
|
// If whole creation failed, but container might have been initialized
|
||||||
|
try {
|
||||||
|
// Try to remove with contaier name instead of ID
|
||||||
|
$orchestration->remove($runtimeId, true);
|
||||||
|
} catch (Throwable $th) {
|
||||||
|
// If fails, means initialization also failed.
|
||||||
|
// Contianer is not there, no need to remove
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release orchestration back to pool, we are done with it
|
||||||
$orchestrationPool->put($orchestration);
|
$orchestrationPool->put($orchestration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue