fix(docker): preserve restart policies when stopping containers
This commit is contained in:
parent
92c0035002
commit
a04c2ecb44
6 changed files with 13 additions and 11 deletions
|
|
@ -44,8 +44,6 @@ public function handle(Application $application, bool $previewDeployments = fals
|
|||
$commands = [dockerStopCommand($timeout, $containerName, $server)];
|
||||
if ($removeContainers) {
|
||||
$commands[] = "docker rm -f $containerName";
|
||||
} else {
|
||||
array_unshift($commands, "docker update --restart=no $containerName");
|
||||
}
|
||||
|
||||
instant_remote_process(command: $commands, server: $server, throwError: false);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ public function handle(ApplicationPreview $preview, bool $resetRestartCount = tr
|
|||
$commands = [dockerStopCommand($application->settings->stopGracePeriodSeconds(), $containerName, $server)];
|
||||
if ($removeContainer) {
|
||||
$commands[] = "docker rm -f $containerName";
|
||||
} else {
|
||||
array_unshift($commands, "docker update --restart=no $containerName");
|
||||
}
|
||||
instant_remote_process($commands, $server, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,6 @@ private function stopContainer(BaseModel $database, string $containerName, int $
|
|||
$commands = [dockerStopCommand($timeout, $containerName, $server)];
|
||||
if ($removeContainer) {
|
||||
$commands[] = "docker rm -f $containerName";
|
||||
} else {
|
||||
array_unshift($commands, "docker update --restart=no $containerName");
|
||||
}
|
||||
instant_remote_process(command: $commands, server: $server, throwError: false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,7 @@ public function handle(ServiceApplication|ServiceDatabase $serviceApplication, b
|
|||
if ($removeContainer) {
|
||||
$commands = ["docker rm -f {$containerName}"];
|
||||
} else {
|
||||
$commands = [
|
||||
"docker update --restart=no {$containerName}",
|
||||
"docker stop {$containerName}",
|
||||
];
|
||||
$commands = ["docker stop {$containerName}"];
|
||||
}
|
||||
instant_remote_process($commands, $server, throwError: ! $removeContainer);
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ function applicationWithRestartState(array $attributes = []): Application
|
|||
|
||||
expect($removeContainers)->not->toBeNull()
|
||||
->and($removeContainers->getDefaultValue())->toBeTrue()
|
||||
->and($action)->toContain('docker update --restart=no')
|
||||
->and($action)->not->toContain('docker update --restart=no')
|
||||
->and($action)->toContain('if ($removeContainers)');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,17 @@
|
|||
expect($action)->toContain("'status' => 'exited'");
|
||||
});
|
||||
|
||||
it('does not change Docker restart policies when retaining stopped containers', function (string $actionPath) {
|
||||
$action = file_get_contents(__DIR__.'/../../'.$actionPath);
|
||||
|
||||
expect($action)->not->toContain('docker update --restart=no');
|
||||
})->with([
|
||||
'applications' => 'app/Actions/Application/StopApplication.php',
|
||||
'application previews' => 'app/Actions/Application/StopApplicationPreview.php',
|
||||
'service applications' => 'app/Actions/Service/StopServiceApplication.php',
|
||||
'standalone databases' => 'app/Actions/Database/StopDatabase.php',
|
||||
]);
|
||||
|
||||
it('persists exited status for every full application stop path', function () {
|
||||
$action = file_get_contents(__DIR__.'/../../app/Actions/Application/StopApplication.php');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue