mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 23:24:46 +02:00
rename "oom_disabled" to "oom_killer" and invert logic
This commit is contained in:
parent
1f5217a9d9
commit
f02eb5bfba
@ -610,7 +610,7 @@ class CreateServer extends CreateRecord
|
||||
->columns(4)
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
Forms\Components\ToggleButtons::make('oom_disabled')
|
||||
Forms\Components\ToggleButtons::make('oom_killer')
|
||||
->label('OOM Killer')
|
||||
->inlineLabel()->inline()
|
||||
->default(false)
|
||||
|
@ -432,7 +432,7 @@ class EditServer extends EditRecord
|
||||
->columns(4)
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
Forms\Components\ToggleButtons::make('oom_disabled')
|
||||
Forms\Components\ToggleButtons::make('oom_killer')
|
||||
->label('OOM Killer')->inlineLabel()->inline()
|
||||
->columnSpan(2)
|
||||
->options([
|
||||
|
@ -126,7 +126,7 @@ class ServersController extends Controller
|
||||
$this->buildModificationService->handle($server, $request->only([
|
||||
'allocation_id', 'add_allocations', 'remove_allocations',
|
||||
'memory', 'swap', 'io', 'cpu', 'threads', 'disk',
|
||||
'database_limit', 'allocation_limit', 'backup_limit', 'oom_disabled',
|
||||
'database_limit', 'allocation_limit', 'backup_limit', 'oom_killer',
|
||||
]));
|
||||
} catch (DataValidationException $exception) {
|
||||
throw new ValidationException($exception->getValidator());
|
||||
|
@ -32,7 +32,7 @@ class StoreServerRequest extends ApplicationApiRequest
|
||||
'startup' => $rules['startup'],
|
||||
'environment' => 'present|array',
|
||||
'skip_scripts' => 'sometimes|boolean',
|
||||
'oom_disabled' => 'sometimes|boolean',
|
||||
'oom_killer' => 'sometimes|boolean',
|
||||
|
||||
// Resource limitations
|
||||
'limits' => 'required|array',
|
||||
@ -94,7 +94,7 @@ class StoreServerRequest extends ApplicationApiRequest
|
||||
'database_limit' => array_get($data, 'feature_limits.databases'),
|
||||
'allocation_limit' => array_get($data, 'feature_limits.allocations'),
|
||||
'backup_limit' => array_get($data, 'feature_limits.backups'),
|
||||
'oom_disabled' => array_get($data, 'oom_disabled'),
|
||||
'oom_killer' => array_get($data, 'oom_killer'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
|
||||
|
||||
return [
|
||||
'allocation' => $rules['allocation_id'],
|
||||
'oom_disabled' => $rules['oom_disabled'],
|
||||
'oom_killer' => $rules['oom_killer'],
|
||||
|
||||
'limits' => 'sometimes|array',
|
||||
'limits.memory' => $this->requiredToOptional('memory', $rules['memory'], true),
|
||||
|
@ -35,7 +35,7 @@ use App\Exceptions\Http\Server\ServerStateConflictException;
|
||||
* @property int $io
|
||||
* @property int $cpu
|
||||
* @property string|null $threads
|
||||
* @property bool $oom_disabled
|
||||
* @property bool $oom_killer
|
||||
* @property int $allocation_id
|
||||
* @property int $egg_id
|
||||
* @property string $startup
|
||||
@ -90,7 +90,7 @@ use App\Exceptions\Http\Server\ServerStateConflictException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereMemory($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereNodeId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereOomDisabled($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereOomKiller($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereOwnerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereSkipScripts($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Server whereStartup($value)
|
||||
@ -124,7 +124,7 @@ class Server extends Model
|
||||
*/
|
||||
protected $attributes = [
|
||||
'status' => ServerState::Installing,
|
||||
'oom_disabled' => true,
|
||||
'oom_killer' => false,
|
||||
'installed_at' => null,
|
||||
];
|
||||
|
||||
@ -150,7 +150,7 @@ class Server extends Model
|
||||
'io' => 'required|numeric|between:0,1000',
|
||||
'cpu' => 'required|numeric|min:0',
|
||||
'threads' => 'nullable|regex:/^[0-9-,]+$/',
|
||||
'oom_disabled' => 'sometimes|boolean',
|
||||
'oom_killer' => 'sometimes|boolean',
|
||||
'disk' => 'required|numeric|min:0',
|
||||
'allocation_id' => 'required|bail|unique:servers|exists:allocations,id',
|
||||
'egg_id' => 'required|exists:eggs,id',
|
||||
@ -174,7 +174,7 @@ class Server extends Model
|
||||
'disk' => 'integer',
|
||||
'io' => 'integer',
|
||||
'cpu' => 'integer',
|
||||
'oom_disabled' => 'boolean',
|
||||
'oom_killer' => 'boolean',
|
||||
'allocation_id' => 'integer',
|
||||
'egg_id' => 'integer',
|
||||
'database_limit' => 'integer',
|
||||
|
@ -41,7 +41,7 @@ class BuildModificationService
|
||||
}
|
||||
|
||||
// If any of these values are passed through in the data array go ahead and set them correctly on the server model.
|
||||
$merge = Arr::only($data, ['oom_disabled', 'memory', 'swap', 'io', 'cpu', 'threads', 'disk', 'allocation_id']);
|
||||
$merge = Arr::only($data, ['oom_killer', 'memory', 'swap', 'io', 'cpu', 'threads', 'disk', 'allocation_id']);
|
||||
|
||||
$server->forceFill(array_merge($merge, [
|
||||
'database_limit' => Arr::get($data, 'database_limit', 0) ?? null,
|
||||
|
@ -59,14 +59,12 @@ class ServerConfigurationStructureService
|
||||
'cpu_limit' => $server->cpu,
|
||||
'threads' => $server->threads,
|
||||
'disk_space' => $server->disk,
|
||||
'oom_disabled' => $server->oom_disabled,
|
||||
// This field is deprecated — use "oom_killer".
|
||||
'oom_disabled' => !$server->oom_killer,
|
||||
'oom_killer' => !$server->oom_killer,
|
||||
],
|
||||
'container' => [
|
||||
'image' => $server->image,
|
||||
// This field is deprecated — use the value in the "build" block.
|
||||
//
|
||||
// TODO: remove this key in V2.
|
||||
'oom_disabled' => $server->oom_disabled,
|
||||
'requires_rebuild' => false,
|
||||
],
|
||||
'allocations' => [
|
||||
@ -110,7 +108,7 @@ class ServerConfigurationStructureService
|
||||
return $item->pluck('port');
|
||||
})->toArray(),
|
||||
'env' => $this->environment->handle($server),
|
||||
'oom_disabled' => $server->oom_disabled,
|
||||
'oom_disabled' => !$server->oom_killer,
|
||||
'memory' => (int) $server->memory,
|
||||
'swap' => (int) $server->swap,
|
||||
'io' => (int) $server->io,
|
||||
|
@ -142,7 +142,7 @@ class ServerCreationService
|
||||
'io' => Arr::get($data, 'io'),
|
||||
'cpu' => Arr::get($data, 'cpu'),
|
||||
'threads' => Arr::get($data, 'threads'),
|
||||
'oom_disabled' => Arr::get($data, 'oom_disabled') ?? true,
|
||||
'oom_killer' => Arr::get($data, 'oom_killer') ?? false,
|
||||
'allocation_id' => Arr::get($data, 'allocation_id'),
|
||||
'egg_id' => Arr::get($data, 'egg_id'),
|
||||
'startup' => Arr::get($data, 'startup'),
|
||||
|
@ -65,7 +65,9 @@ class ServerTransformer extends BaseTransformer
|
||||
'io' => $server->io,
|
||||
'cpu' => $server->cpu,
|
||||
'threads' => $server->threads,
|
||||
'oom_disabled' => $server->oom_disabled,
|
||||
// This field is deprecated, please use "oom_killer".
|
||||
'oom_disabled' => !$server->oom_killer,
|
||||
'oom_killer' => $server->oom_killer,
|
||||
],
|
||||
'feature_limits' => [
|
||||
'databases' => $server->database_limit,
|
||||
|
@ -56,7 +56,9 @@ class ServerTransformer extends BaseClientTransformer
|
||||
'io' => $server->io,
|
||||
'cpu' => $server->cpu,
|
||||
'threads' => $server->threads,
|
||||
'oom_disabled' => $server->oom_disabled,
|
||||
// This field is deprecated, please use "oom_killer".
|
||||
'oom_disabled' => !$server->oom_killer,
|
||||
'oom_killer' => $server->oom_killer,
|
||||
],
|
||||
'invocation' => $service->handle($server, !$user->can(Permission::ACTION_STARTUP_READ, $server)),
|
||||
'docker_image' => $server->image,
|
||||
|
@ -35,7 +35,7 @@ class ServerFactory extends Factory
|
||||
'io' => 500,
|
||||
'cpu' => 0,
|
||||
'threads' => null,
|
||||
'oom_disabled' => 0,
|
||||
'oom_killer' => false,
|
||||
'startup' => '/bin/bash echo "hello world"',
|
||||
'image' => 'foo/bar:latest',
|
||||
'allocation_limit' => null,
|
||||
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->tinyInteger('oom_killer')->unsigned()->default(0)->after('oom_disabled');
|
||||
});
|
||||
|
||||
DB::table('servers')->select(['id', 'oom_disabled'])->cursor()->each(function ($server) {
|
||||
DB::table('servers')->where('id', $server->id)->update(['oom_killer' => !$server->oom_disabled]);
|
||||
});
|
||||
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->dropColumn('oom_disabled');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->tinyInteger('oom_disabled')->unsigned()->default(0)->after('oom_killer');
|
||||
});
|
||||
|
||||
DB::table('servers')->select(['id', 'oom_killer'])->cursor()->each(function ($server) {
|
||||
DB::table('servers')->where('id', $server->id)->update(['oom_disabled' => !$server->oom_killer]);
|
||||
});
|
||||
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->dropColumn('oom_killer');
|
||||
});
|
||||
}
|
||||
};
|
@ -495,7 +495,7 @@ CREATE TABLE `servers` (
|
||||
`io` int unsigned NOT NULL,
|
||||
`cpu` int unsigned NOT NULL,
|
||||
`threads` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`oom_disabled` tinyint unsigned NOT NULL DEFAULT '0',
|
||||
`oom_killer` tinyint unsigned NOT NULL DEFAULT '0',
|
||||
`allocation_id` int unsigned NOT NULL,
|
||||
`egg_id` int unsigned NOT NULL,
|
||||
`startup` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
|
@ -203,8 +203,8 @@
|
||||
</div>
|
||||
<div class="form-group col-xs-12">
|
||||
<div class="checkbox checkbox-primary no-margin-bottom">
|
||||
<input type="checkbox" id="pOomDisabled" name="oom_disabled" value="0" {{ \App\Helpers\Utilities::checked('oom_disabled', 0) }} />
|
||||
<label for="pOomDisabled" class="strong">Enable OOM Killer</label>
|
||||
<input type="checkbox" id="pOomKiller" name="oom_killer" value="0" {{ \App\Helpers\Utilities::checked('oom_killer', 0) }} />
|
||||
<label for="pOomKiller" class="strong">Enable OOM Killer</label>
|
||||
</div>
|
||||
|
||||
<p class="small text-muted no-margin">Terminates the server if it breaches the memory limits. Enabling OOM killer may cause server processes to exit unexpectedly.</p>
|
||||
|
@ -74,11 +74,11 @@
|
||||
<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>
|
||||
<input type="radio" id="pOomKillerEnabled" value="1" name="oom_killer" @if(!$server->oom_killer)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>
|
||||
<input type="radio" id="pOomKillerDisabled" value="0" name="oom_killer" @if($server->oom_killer)checked @endif>
|
||||
<label for="pOomKillerDisabled">Disabled</label>
|
||||
</div>
|
||||
<p class="text-muted small">
|
||||
|
@ -114,7 +114,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||
$this->daemonServerRepository->expects('sync')->withNoArgs()->andReturnUndefined();
|
||||
|
||||
$response = $this->getService()->handle($server, [
|
||||
'oom_disabled' => false,
|
||||
'oom_killer' => false,
|
||||
'memory' => 256,
|
||||
'swap' => 128,
|
||||
'io' => 600,
|
||||
@ -126,7 +126,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||
'allocation_limit' => 20,
|
||||
]);
|
||||
|
||||
$this->assertFalse($response->oom_disabled);
|
||||
$this->assertFalse($response->oom_killer);
|
||||
$this->assertSame(256, $response->memory);
|
||||
$this->assertSame(128, $response->swap);
|
||||
$this->assertSame(600, $response->io);
|
||||
|
@ -138,7 +138,7 @@ class ServerCreationServiceTest extends IntegrationTestCase
|
||||
$this->assertSame($allocations[4]->id, $response->allocations[1]->id);
|
||||
|
||||
$this->assertFalse($response->isSuspended());
|
||||
$this->assertTrue($response->oom_disabled);
|
||||
$this->assertFalse($response->oom_killer);
|
||||
$this->assertSame(0, $response->database_limit);
|
||||
$this->assertSame(0, $response->allocation_limit);
|
||||
$this->assertSame(0, $response->backup_limit);
|
||||
|
Loading…
x
Reference in New Issue
Block a user