From a4f6870518f10855a063f19fc4dc69b9e83c070f Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Mon, 21 Nov 2022 15:53:54 -0500 Subject: [PATCH] server: track reinstall failures differently from initial install failures (#4531) --- .../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 e78843763..8fcfbe064 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php @@ -48,8 +48,18 @@ class ServerInstallController extends Controller 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 c5d1973ec..13b3e77d7 100644 --- a/app/Http/Requests/Api/Remote/InstallationDataRequest.php +++ b/app/Http/Requests/Api/Remote/InstallationDataRequest.php @@ -15,6 +15,7 @@ class InstallationDataRequest extends FormRequest { return [ 'successful' => 'present|boolean', + 'reinstall' => 'sometimes|boolean', ]; } } diff --git a/app/Models/Server.php b/app/Models/Server.php index d7cc649c0..5f2d6a49e 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';