Skip to content

Commit 8140994

Browse files
committed
Default to OOM killer being disabled, add back configuration option per-server
1 parent 2198269 commit 8140994

File tree

9 files changed

+38
-3
lines changed

9 files changed

+38
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ error encountered during creation or update.
2121
* Client API endpoint to list all servers now supports an additional `?filter=subuser-of|all|admin|owner` parameter to
2222
return different groupings of servers. The default value is `subuser-of` which will include all of the user's servers
2323
that they are the owner of, as well as all servers they're a subuser of.
24+
* Added back ability to toggle OOM killer status on a per-server basis.
2425

2526
### Changed
2627
* Updated Paper egg to not download `server.properties` each time. [parkervcp/eggs#260](https://github.com/parkervcp/eggs/issues/260)
2728
* Insurgency egg now uses the proper dedicated server ID.
2829
* Teamspeak egg updated with improved installation process and grabbing latest versions.
30+
* OOM killer disabled by default on all new servers.
2931

3032
## v0.7.14 (Derelict Dermodactylus)
3133
### Fixed

app/Http/Controllers/Admin/ServersController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public function updateBuild(Request $request, Server $server)
516516
$this->buildModificationService->handle($server, $request->only([
517517
'allocation_id', 'add_allocations', 'remove_allocations',
518518
'memory', 'swap', 'io', 'cpu', 'disk',
519-
'database_limit', 'allocation_limit',
519+
'database_limit', 'allocation_limit', 'oom_disabled',
520520
]));
521521
$this->alert->success(trans('admin/server.alerts.build_updated'))->flash();
522522

app/Http/Requests/Api/Application/Servers/StoreServerRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function rules(): array
4141
'startup' => $rules['startup'],
4242
'environment' => 'present|array',
4343
'skip_scripts' => 'sometimes|boolean',
44+
'oom_disabled' => 'sometimes|boolean',
4445

4546
// Resource limitations
4647
'limits' => 'required|array',

app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function rules(): array
1818

1919
return [
2020
'allocation' => $rules['allocation_id'],
21+
'oom_disabled' => $rules['oom_disabled'],
2122

2223
'limits' => 'sometimes|array',
2324
'limits.memory' => $this->requiredToOptional('memory', $rules['memory'], true),

app/Models/Server.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ class Server extends Model implements CleansAttributes, ValidableContract
2828
*/
2929
protected $table = 'servers';
3030

31+
/**
32+
* Default values when creating the model. We want to switch to disabling OOM killer
33+
* on server instances unless the user specifies otherwise in the request.
34+
*
35+
* @var array
36+
*/
37+
protected $attributes = [
38+
'oom_disabled' => true,
39+
];
40+
3141
/**
3242
* The attributes that should be mutated to dates.
3343
*
@@ -53,6 +63,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
5363
'swap' => 'required',
5464
'io' => 'required',
5565
'cpu' => 'required',
66+
'oom_disabled' => 'sometimes',
5667
'disk' => 'required',
5768
'nest_id' => 'required',
5869
'egg_id' => 'required',
@@ -79,6 +90,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
7990
'swap' => 'numeric|min:-1',
8091
'io' => 'numeric|between:10,1000',
8192
'cpu' => 'numeric|min:0',
93+
'oom_disabled' => 'boolean',
8294
'disk' => 'numeric|min:0',
8395
'allocation_id' => 'bail|unique:servers|exists:allocations,id',
8496
'nest_id' => 'exists:nests,id',
@@ -107,7 +119,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
107119
'disk' => 'integer',
108120
'io' => 'integer',
109121
'cpu' => 'integer',
110-
'oom_disabled' => 'integer',
122+
'oom_disabled' => 'boolean',
111123
'allocation_id' => 'integer',
112124
'nest_id' => 'integer',
113125
'egg_id' => 'integer',

app/Services/Servers/BuildModificationService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function handle(Server $server, array $data)
8585
}
8686

8787
$server = $this->repository->withFreshModel()->update($server->id, [
88+
'oom_disabled' => array_get($data, 'oom_disabled'),
8889
'memory' => array_get($data, 'memory'),
8990
'swap' => array_get($data, 'swap'),
9091
'io' => array_get($data, 'io'),
@@ -97,6 +98,7 @@ public function handle(Server $server, array $data)
9798

9899
$allocations = $this->allocationRepository->findWhere([['server_id', '=', $server->id]]);
99100

101+
$build['oom_disabled'] = $server->oom_disabled;
100102
$build['memory'] = (int) $server->memory;
101103
$build['swap'] = (int) $server->swap;
102104
$build['io'] = (int) $server->io;

app/Services/Servers/ServerConfigurationStructureService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function handle(Server $server): array
7070
return $item->pluck('port');
7171
})->toArray(),
7272
'env' => $this->environment->handle($server),
73+
'oom_disabled' => $server->oom_disabled,
7374
'memory' => (int) $server->memory,
7475
'swap' => (int) $server->swap,
7576
'io' => (int) $server->io,

app/Services/Servers/ServerCreationService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private function createModel(array $data): Server
227227
'disk' => array_get($data, 'disk'),
228228
'io' => array_get($data, 'io'),
229229
'cpu' => array_get($data, 'cpu'),
230-
'oom_disabled' => false,
230+
'oom_disabled' => array_get($data, 'oom_disabled', true),
231231
'allocation_id' => array_get($data, 'allocation_id'),
232232
'nest_id' => array_get($data, 'nest_id'),
233233
'egg_id' => array_get($data, 'egg_id'),

resources/themes/pterodactyl/admin/servers/view/build.blade.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@
8585
</div>
8686
<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>
8787
</div>
88+
<div class="form-group">
89+
<label for="cpu" class="control-label">OOM Killer</label>
90+
<div>
91+
<div class="radio radio-danger radio-inline">
92+
<input type="radio" id="pOomKillerEnabled" value="0" name="oom_disabled" @if(!$server->oom_disabled)checked @endif>
93+
<label for="pOomKillerEnabled">Enabled</label>
94+
</div>
95+
<div class="radio radio-success radio-inline">
96+
<input type="radio" id="pOomKillerDisabled" value="1" name="oom_disabled" @if($server->oom_disabled)checked @endif>
97+
<label for="pOomKillerDisabled">Disabled</label>
98+
</div>
99+
<p class="text-muted small">
100+
Enabling OOM killer may cause server processes to exit unexpectedly.
101+
</p>
102+
</div>
103+
</div>
88104
</div>
89105
</div>
90106
</div>

0 commit comments

Comments
 (0)