Apply node maintenance mode to servers (#4421)
This commit is contained in:
parent
4032481a4f
commit
032e4f2e31
11 changed files with 29 additions and 5 deletions
|
@ -17,6 +17,8 @@ class ServerStateConflictException extends ConflictHttpException
|
|||
$message = 'This server is currently in an unsupported state, please try again later.';
|
||||
if ($server->isSuspended()) {
|
||||
$message = 'This server is currently suspended and the functionality requested is unavailable.';
|
||||
} elseif ($server->node->isUnderMaintenance()) {
|
||||
$message = 'The node of this server is currently under maintenance and the functionality requested is unavailable.';
|
||||
} elseif (!$server->isInstalled()) {
|
||||
$message = 'This server has not yet completed its installation process, please try again later.';
|
||||
} elseif ($server->status === Server::STATUS_RESTORING_BACKUP) {
|
||||
|
|
|
@ -53,7 +53,7 @@ class AuthenticateServerAccess
|
|||
// Still allow users to get information about their server if it is installing or
|
||||
// being transferred.
|
||||
if (!$request->routeIs('api:client:server.view')) {
|
||||
if ($server->isSuspended() && !$request->routeIs('api:client:server.resources')) {
|
||||
if (($server->isSuspended() || $server->node->isUnderMaintenance()) && !$request->routeIs('api:client:server.resources')) {
|
||||
throw $exception;
|
||||
}
|
||||
if (!$user->root_admin || !$request->routeIs($this->except)) {
|
||||
|
|
|
@ -24,6 +24,7 @@ class StoreNodeRequest extends ApplicationApiRequest
|
|||
'fqdn',
|
||||
'scheme',
|
||||
'behind_proxy',
|
||||
'maintenance_mode',
|
||||
'memory',
|
||||
'memory_overallocate',
|
||||
'disk',
|
||||
|
|
|
@ -186,6 +186,11 @@ class Node extends Model
|
|||
);
|
||||
}
|
||||
|
||||
public function isUnderMaintenance(): bool
|
||||
{
|
||||
return $this->maintenance_mode;
|
||||
}
|
||||
|
||||
public function mounts(): HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(Mount::class, MountNode::class, 'node_id', 'id', 'id', 'mount_id');
|
||||
|
|
|
@ -354,6 +354,7 @@ class Server extends Model
|
|||
{
|
||||
if (
|
||||
$this->isSuspended() ||
|
||||
$this->node->isUnderMaintenance() ||
|
||||
!$this->isInstalled() ||
|
||||
$this->status === self::STATUS_RESTORING_BACKUP ||
|
||||
!is_null($this->transfer)
|
||||
|
|
|
@ -43,6 +43,7 @@ class ServerTransformer extends BaseClientTransformer
|
|||
'uuid' => $server->uuid,
|
||||
'name' => $server->name,
|
||||
'node' => $server->node->name,
|
||||
'is_node_under_maintenance' => $server->node->isUnderMaintenance(),
|
||||
'sftp_details' => [
|
||||
'ip' => $server->node->fqdn,
|
||||
'port' => $server->node->daemonSFTP,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue