Skip to content

Commit

Permalink
server: track reinstall failures differently from initial install fai…
Browse files Browse the repository at this point in the history
…lures (pterodactyl#4531)
  • Loading branch information
lancepioch authored Nov 21, 2022
1 parent 039ad4a commit a4f6870
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions app/Http/Requests/Api/Remote/InstallationDataRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function rules(): array
{
return [
'successful' => 'present|boolean',
'reinstall' => 'sometimes|boolean',
];
}
}
1 change: 1 addition & 0 deletions app/Models/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit a4f6870

Please sign in to comment.