From 155460ce7074edafa2493eacdc09becc152baa1f Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 6 Nov 2022 11:32:48 -0500 Subject: [PATCH] Handle reinstall failures differently from normal installation failures --- .../Api/Remote/Servers/ServerInstallController.php | 12 +++++++++++- .../Requests/Api/Remote/InstallationDataRequest.php | 1 + app/Models/Server.php | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php index e788437631..8fcfbe0643 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php @@ -48,8 +48,18 @@ public function index(Request $request, string $uuid): JsonResponse public function store(InstallationDataRequest $request, string $uuid): JsonResponse { $server = $this->repository->getByUuid($uuid); + $status = null; - $status = $request->boolean('successful') ? null : Server::STATUS_INSTALL_FAILED; + // Make sure the type of failure is accurate + if (!$request->boolean('successful')) { + $status = Server::STATUS_INSTALL_FAILED; + + if ($request->boolean('reinstall')) { + $status = Server::STATUS_REINSTALL_FAILED; + } + } + + // Keep the server suspended if it's already suspended if ($server->status === Server::STATUS_SUSPENDED) { $status = Server::STATUS_SUSPENDED; } diff --git a/app/Http/Requests/Api/Remote/InstallationDataRequest.php b/app/Http/Requests/Api/Remote/InstallationDataRequest.php index c5d1973ec4..13b3e77d7a 100644 --- a/app/Http/Requests/Api/Remote/InstallationDataRequest.php +++ b/app/Http/Requests/Api/Remote/InstallationDataRequest.php @@ -15,6 +15,7 @@ public function rules(): array { return [ 'successful' => 'present|boolean', + 'reinstall' => 'sometimes|boolean', ]; } } diff --git a/app/Models/Server.php b/app/Models/Server.php index 5ad99151a3..0bddec6134 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -115,6 +115,7 @@ class Server extends Model public const STATUS_INSTALLING = 'installing'; public const STATUS_INSTALL_FAILED = 'install_failed'; + public const STATUS_REINSTALL_FAILED = 'reinstall_failed'; public const STATUS_SUSPENDED = 'suspended'; public const STATUS_RESTORING_BACKUP = 'restoring_backup';