From 450fba00bc0befd649f86be5cfd875bb48575072 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Tue, 17 Jan 2023 11:43:26 -0700 Subject: [PATCH] ui(admin): fix oom killer setting toggle --- app/Transformers/Api/Application/ServerTransformer.php | 2 +- resources/scripts/api/admin/server.ts | 2 +- resources/scripts/api/admin/servers/createServer.ts | 4 ++-- resources/scripts/api/admin/servers/getServers.ts | 4 ++-- resources/scripts/api/admin/servers/updateServer.ts | 4 ++-- resources/scripts/api/definitions/admin/transformers.ts | 4 ++-- .../components/admin/servers/NewServerContainer.tsx | 4 +--- .../components/admin/servers/ServerSettingsContainer.tsx | 6 +----- .../admin/servers/settings/ServerResourceBox.tsx | 2 +- resources/scripts/components/elements/ContentBox.tsx | 9 +++++---- 10 files changed, 18 insertions(+), 23 deletions(-) diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index a22b85771..f76f192d9 100644 --- a/app/Transformers/Api/Application/ServerTransformer.php +++ b/app/Transformers/Api/Application/ServerTransformer.php @@ -64,7 +64,7 @@ class ServerTransformer extends Transformer 'disk' => $model->disk, 'io' => $model->io, 'memory' => $model->memory, - 'oom_disabled' => $model->oom_disabled, + 'oom_killer' => !$model->oom_disabled, 'swap' => $model->swap, 'threads' => $model->threads, ], diff --git a/resources/scripts/api/admin/server.ts b/resources/scripts/api/admin/server.ts index 219c17a08..652d3ddde 100644 --- a/resources/scripts/api/admin/server.ts +++ b/resources/scripts/api/admin/server.ts @@ -18,7 +18,7 @@ interface ServerLimits { io: number; cpu: number; threads: string | null; - oomDisabled: boolean; + oomKiller: boolean; } export interface ServerVariable extends EggVariable { diff --git a/resources/scripts/api/admin/servers/createServer.ts b/resources/scripts/api/admin/servers/createServer.ts index 6421aece6..2ffe83739 100644 --- a/resources/scripts/api/admin/servers/createServer.ts +++ b/resources/scripts/api/admin/servers/createServer.ts @@ -15,7 +15,7 @@ export interface CreateServerRequest { io: number; cpu: number; threads: string; - oomDisabled: boolean; + oomKiller: boolean; }; featureLimits: { @@ -55,7 +55,7 @@ export default (r: CreateServerRequest, include: string[] = []): Promise memory: r.limits.memory, swap: r.limits.swap, threads: r.limits.threads, - oom_killer: r.limits.oomDisabled, + oom_killer: r.limits.oomKiller, }, feature_limits: { diff --git a/resources/scripts/api/admin/servers/getServers.ts b/resources/scripts/api/admin/servers/getServers.ts index cef280319..23ef3805b 100644 --- a/resources/scripts/api/admin/servers/getServers.ts +++ b/resources/scripts/api/admin/servers/getServers.ts @@ -55,7 +55,7 @@ export interface Server { io: number; cpu: number; threads: string | null; - oomDisabled: boolean; + oomKiller: boolean; }; featureLimits: { @@ -105,7 +105,7 @@ export const rawDataToServer = ({ attributes }: FractalResponseData): Server => io: attributes.limits.io, cpu: attributes.limits.cpu, threads: attributes.limits.threads, - oomDisabled: attributes.limits.oom_disabled, + oomKiller: attributes.limits.oom_killer, }, featureLimits: { diff --git a/resources/scripts/api/admin/servers/updateServer.ts b/resources/scripts/api/admin/servers/updateServer.ts index cf133431b..25c1b8b0d 100644 --- a/resources/scripts/api/admin/servers/updateServer.ts +++ b/resources/scripts/api/admin/servers/updateServer.ts @@ -13,7 +13,7 @@ export interface Values { io: number; cpu: number; threads: string; - oomDisabled: boolean; + oomKiller: boolean; }; featureLimits: { @@ -43,7 +43,7 @@ export default (id: number, server: Partial, include: string[] = []): Pr io: server.limits?.io, cpu: server.limits?.cpu, threads: server.limits?.threads, - oom_killer: server.limits?.oomDisabled, + oom_killer: server.limits?.oomKiller, }, feature_limits: { diff --git a/resources/scripts/api/definitions/admin/transformers.ts b/resources/scripts/api/definitions/admin/transformers.ts index 093b022d8..d298341e8 100644 --- a/resources/scripts/api/definitions/admin/transformers.ts +++ b/resources/scripts/api/definitions/admin/transformers.ts @@ -40,7 +40,7 @@ function transform( export default class Transformers { static toServer = ({ attributes }: FractalResponseData): Server => { - const { oom_disabled, ...limits } = attributes.limits; + const { oom_killer, ...limits } = attributes.limits; const { allocations, egg, nest, node, user, variables } = attributes.relationships || {}; return { @@ -56,7 +56,7 @@ export default class Transformers { allocationId: attributes.allocation_id, eggId: attributes.egg_id, nestId: attributes.nest_id, - limits: { ...limits, oomDisabled: oom_disabled }, + limits: { ...limits, oomKiller: oom_killer }, featureLimits: attributes.feature_limits, container: attributes.container, createdAt: new Date(attributes.created_at), diff --git a/resources/scripts/components/admin/servers/NewServerContainer.tsx b/resources/scripts/components/admin/servers/NewServerContainer.tsx index f195b5c73..e001caa20 100644 --- a/resources/scripts/components/admin/servers/NewServerContainer.tsx +++ b/resources/scripts/components/admin/servers/NewServerContainer.tsx @@ -195,9 +195,7 @@ export default () => { io: 500, cpu: 0, threads: '', - // This value is inverted to have the switch be on when the - // OOM Killer is enabled, rather than when disabled. - oomDisabled: false, + oomKiller: true, }, featureLimits: { allocations: 1, diff --git a/resources/scripts/components/admin/servers/ServerSettingsContainer.tsx b/resources/scripts/components/admin/servers/ServerSettingsContainer.tsx index 658eb6744..144102c5e 100644 --- a/resources/scripts/components/admin/servers/ServerSettingsContainer.tsx +++ b/resources/scripts/components/admin/servers/ServerSettingsContainer.tsx @@ -23,10 +23,6 @@ export default () => { const submit = (values: Values, { setSubmitting, setFieldValue }: FormikHelpers) => { clearFlashes('server'); - // This value is inverted to have the switch be on when the - // OOM Killer is enabled, rather than when disabled. - values.limits.oomDisabled = !values.limits.oomDisabled; - updateServer(server.id, values) .then(() => { // setServer({ ...server, ...s }); @@ -58,7 +54,7 @@ export default () => { threads: server.limits.threads || '', // This value is inverted to have the switch be on when the // OOM Killer is enabled, rather than when disabled. - oomDisabled: !server.limits.oomDisabled, + oomKiller: server.limits.oomKiller, }, featureLimits: { allocations: server.featureLimits.allocations, diff --git a/resources/scripts/components/admin/servers/settings/ServerResourceBox.tsx b/resources/scripts/components/admin/servers/settings/ServerResourceBox.tsx index 69312ec3e..b8583c5fc 100644 --- a/resources/scripts/components/admin/servers/settings/ServerResourceBox.tsx +++ b/resources/scripts/components/admin/servers/settings/ServerResourceBox.tsx @@ -60,7 +60,7 @@ export default () => { />
, HTMLDivElement> & { + DetailedHTMLProps, HTMLDivElement> & { title?: string; borderColor?: string; showFlashes?: string | boolean;