Default to OOM killer being disabled, add back configuration option per-server

This commit is contained in:
Dane Everitt 2019-08-03 13:41:24 -07:00
parent 2198269a65
commit 81409947cf
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
9 changed files with 38 additions and 3 deletions

View file

@ -21,11 +21,13 @@ error encountered during creation or update.
* Client API endpoint to list all servers now supports an additional `?filter=subuser-of|all|admin|owner` parameter to
return different groupings of servers. The default value is `subuser-of` which will include all of the user's servers
that they are the owner of, as well as all servers they're a subuser of.
* Added back ability to toggle OOM killer status on a per-server basis.
### Changed
* Updated Paper egg to not download `server.properties` each time. [parkervcp/eggs#260](https://github.com/parkervcp/eggs/issues/260)
* Insurgency egg now uses the proper dedicated server ID.
* Teamspeak egg updated with improved installation process and grabbing latest versions.
* OOM killer disabled by default on all new servers.
## v0.7.14 (Derelict Dermodactylus)
### Fixed

View file

@ -516,7 +516,7 @@ class ServersController extends Controller
$this->buildModificationService->handle($server, $request->only([
'allocation_id', 'add_allocations', 'remove_allocations',
'memory', 'swap', 'io', 'cpu', 'disk',
'database_limit', 'allocation_limit',
'database_limit', 'allocation_limit', 'oom_disabled',
]));
$this->alert->success(trans('admin/server.alerts.build_updated'))->flash();

View file

@ -41,6 +41,7 @@ class StoreServerRequest extends ApplicationApiRequest
'startup' => $rules['startup'],
'environment' => 'present|array',
'skip_scripts' => 'sometimes|boolean',
'oom_disabled' => 'sometimes|boolean',
// Resource limitations
'limits' => 'required|array',

View file

@ -18,6 +18,7 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
return [
'allocation' => $rules['allocation_id'],
'oom_disabled' => $rules['oom_disabled'],
'limits' => 'sometimes|array',
'limits.memory' => $this->requiredToOptional('memory', $rules['memory'], true),

View file

@ -28,6 +28,16 @@ class Server extends Model implements CleansAttributes, ValidableContract
*/
protected $table = 'servers';
/**
* Default values when creating the model. We want to switch to disabling OOM killer
* on server instances unless the user specifies otherwise in the request.
*
* @var array
*/
protected $attributes = [
'oom_disabled' => true,
];
/**
* The attributes that should be mutated to dates.
*
@ -53,6 +63,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
'swap' => 'required',
'io' => 'required',
'cpu' => 'required',
'oom_disabled' => 'sometimes',
'disk' => 'required',
'nest_id' => 'required',
'egg_id' => 'required',
@ -79,6 +90,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
'swap' => 'numeric|min:-1',
'io' => 'numeric|between:10,1000',
'cpu' => 'numeric|min:0',
'oom_disabled' => 'boolean',
'disk' => 'numeric|min:0',
'allocation_id' => 'bail|unique:servers|exists:allocations,id',
'nest_id' => 'exists:nests,id',
@ -107,7 +119,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
'disk' => 'integer',
'io' => 'integer',
'cpu' => 'integer',
'oom_disabled' => 'integer',
'oom_disabled' => 'boolean',
'allocation_id' => 'integer',
'nest_id' => 'integer',
'egg_id' => 'integer',

View file

@ -85,6 +85,7 @@ class BuildModificationService
}
$server = $this->repository->withFreshModel()->update($server->id, [
'oom_disabled' => array_get($data, 'oom_disabled'),
'memory' => array_get($data, 'memory'),
'swap' => array_get($data, 'swap'),
'io' => array_get($data, 'io'),
@ -97,6 +98,7 @@ class BuildModificationService
$allocations = $this->allocationRepository->findWhere([['server_id', '=', $server->id]]);
$build['oom_disabled'] = $server->oom_disabled;
$build['memory'] = (int) $server->memory;
$build['swap'] = (int) $server->swap;
$build['io'] = (int) $server->io;

View file

@ -70,6 +70,7 @@ class ServerConfigurationStructureService
return $item->pluck('port');
})->toArray(),
'env' => $this->environment->handle($server),
'oom_disabled' => $server->oom_disabled,
'memory' => (int) $server->memory,
'swap' => (int) $server->swap,
'io' => (int) $server->io,

View file

@ -227,7 +227,7 @@ class ServerCreationService
'disk' => array_get($data, 'disk'),
'io' => array_get($data, 'io'),
'cpu' => array_get($data, 'cpu'),
'oom_disabled' => false,
'oom_disabled' => array_get($data, 'oom_disabled', true),
'allocation_id' => array_get($data, 'allocation_id'),
'nest_id' => array_get($data, 'nest_id'),
'egg_id' => array_get($data, 'egg_id'),

View file

@ -85,6 +85,22 @@
</div>
<p class="text-muted small">This server will not be allowed to boot if it is using more than this amount of space. If a server goes over this limit while running it will be safely stopped and locked until enough space is available.</p>
</div>
<div class="form-group">
<label for="cpu" class="control-label">OOM Killer</label>
<div>
<div class="radio radio-danger radio-inline">
<input type="radio" id="pOomKillerEnabled" value="0" name="oom_disabled" @if(!$server->oom_disabled)checked @endif>
<label for="pOomKillerEnabled">Enabled</label>
</div>
<div class="radio radio-success radio-inline">
<input type="radio" id="pOomKillerDisabled" value="1" name="oom_disabled" @if($server->oom_disabled)checked @endif>
<label for="pOomKillerDisabled">Disabled</label>
</div>
<p class="text-muted small">
Enabling OOM killer may cause server processes to exit unexpectedly.
</p>
</div>
</div>
</div>
</div>
</div>