From 81409947cf04fb820329a73e9d61951d4128c40a Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 3 Aug 2019 13:41:24 -0700 Subject: [PATCH] Default to OOM killer being disabled, add back configuration option per-server --- CHANGELOG.md | 2 ++ app/Http/Controllers/Admin/ServersController.php | 2 +- .../Application/Servers/StoreServerRequest.php | 1 + .../UpdateServerBuildConfigurationRequest.php | 1 + app/Models/Server.php | 14 +++++++++++++- .../Servers/BuildModificationService.php | 2 ++ .../ServerConfigurationStructureService.php | 1 + app/Services/Servers/ServerCreationService.php | 2 +- .../admin/servers/view/build.blade.php | 16 ++++++++++++++++ 9 files changed, 38 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 252268149..7d41ced77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 44eebcccf..1dc957033 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -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(); diff --git a/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php b/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php index e504d7549..4378474b0 100644 --- a/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php +++ b/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php @@ -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', diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php index 07bbc3281..0238cdcfe 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php @@ -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), diff --git a/app/Models/Server.php b/app/Models/Server.php index 7c2adf047..174453cfb 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -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', diff --git a/app/Services/Servers/BuildModificationService.php b/app/Services/Servers/BuildModificationService.php index 5d36b4c5c..a662cd7b9 100644 --- a/app/Services/Servers/BuildModificationService.php +++ b/app/Services/Servers/BuildModificationService.php @@ -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; diff --git a/app/Services/Servers/ServerConfigurationStructureService.php b/app/Services/Servers/ServerConfigurationStructureService.php index 21b52ad2a..46a710924 100644 --- a/app/Services/Servers/ServerConfigurationStructureService.php +++ b/app/Services/Servers/ServerConfigurationStructureService.php @@ -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, diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index 4b4c4ef89..e9287caae 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -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'), diff --git a/resources/themes/pterodactyl/admin/servers/view/build.blade.php b/resources/themes/pterodactyl/admin/servers/view/build.blade.php index 7f39c24ca..dde0617d2 100644 --- a/resources/themes/pterodactyl/admin/servers/view/build.blade.php +++ b/resources/themes/pterodactyl/admin/servers/view/build.blade.php @@ -85,6 +85,22 @@

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.

+
+ +
+
+ oom_disabled)checked @endif> + +
+
+ oom_disabled)checked @endif> + +
+

+ Enabling OOM killer may cause server processes to exit unexpectedly. +

+
+