ui(admin): fix oom killer setting toggle
This commit is contained in:
parent
f6cf4a1236
commit
450fba00bc
10 changed files with 18 additions and 23 deletions
|
@ -64,7 +64,7 @@ class ServerTransformer extends Transformer
|
||||||
'disk' => $model->disk,
|
'disk' => $model->disk,
|
||||||
'io' => $model->io,
|
'io' => $model->io,
|
||||||
'memory' => $model->memory,
|
'memory' => $model->memory,
|
||||||
'oom_disabled' => $model->oom_disabled,
|
'oom_killer' => !$model->oom_disabled,
|
||||||
'swap' => $model->swap,
|
'swap' => $model->swap,
|
||||||
'threads' => $model->threads,
|
'threads' => $model->threads,
|
||||||
],
|
],
|
||||||
|
|
|
@ -18,7 +18,7 @@ interface ServerLimits {
|
||||||
io: number;
|
io: number;
|
||||||
cpu: number;
|
cpu: number;
|
||||||
threads: string | null;
|
threads: string | null;
|
||||||
oomDisabled: boolean;
|
oomKiller: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServerVariable extends EggVariable {
|
export interface ServerVariable extends EggVariable {
|
||||||
|
|
|
@ -15,7 +15,7 @@ export interface CreateServerRequest {
|
||||||
io: number;
|
io: number;
|
||||||
cpu: number;
|
cpu: number;
|
||||||
threads: string;
|
threads: string;
|
||||||
oomDisabled: boolean;
|
oomKiller: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
featureLimits: {
|
featureLimits: {
|
||||||
|
@ -55,7 +55,7 @@ export default (r: CreateServerRequest, include: string[] = []): Promise<Server>
|
||||||
memory: r.limits.memory,
|
memory: r.limits.memory,
|
||||||
swap: r.limits.swap,
|
swap: r.limits.swap,
|
||||||
threads: r.limits.threads,
|
threads: r.limits.threads,
|
||||||
oom_killer: r.limits.oomDisabled,
|
oom_killer: r.limits.oomKiller,
|
||||||
},
|
},
|
||||||
|
|
||||||
feature_limits: {
|
feature_limits: {
|
||||||
|
|
|
@ -55,7 +55,7 @@ export interface Server {
|
||||||
io: number;
|
io: number;
|
||||||
cpu: number;
|
cpu: number;
|
||||||
threads: string | null;
|
threads: string | null;
|
||||||
oomDisabled: boolean;
|
oomKiller: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
featureLimits: {
|
featureLimits: {
|
||||||
|
@ -105,7 +105,7 @@ export const rawDataToServer = ({ attributes }: FractalResponseData): Server =>
|
||||||
io: attributes.limits.io,
|
io: attributes.limits.io,
|
||||||
cpu: attributes.limits.cpu,
|
cpu: attributes.limits.cpu,
|
||||||
threads: attributes.limits.threads,
|
threads: attributes.limits.threads,
|
||||||
oomDisabled: attributes.limits.oom_disabled,
|
oomKiller: attributes.limits.oom_killer,
|
||||||
},
|
},
|
||||||
|
|
||||||
featureLimits: {
|
featureLimits: {
|
||||||
|
|
|
@ -13,7 +13,7 @@ export interface Values {
|
||||||
io: number;
|
io: number;
|
||||||
cpu: number;
|
cpu: number;
|
||||||
threads: string;
|
threads: string;
|
||||||
oomDisabled: boolean;
|
oomKiller: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
featureLimits: {
|
featureLimits: {
|
||||||
|
@ -43,7 +43,7 @@ export default (id: number, server: Partial<Values>, include: string[] = []): Pr
|
||||||
io: server.limits?.io,
|
io: server.limits?.io,
|
||||||
cpu: server.limits?.cpu,
|
cpu: server.limits?.cpu,
|
||||||
threads: server.limits?.threads,
|
threads: server.limits?.threads,
|
||||||
oom_killer: server.limits?.oomDisabled,
|
oom_killer: server.limits?.oomKiller,
|
||||||
},
|
},
|
||||||
|
|
||||||
feature_limits: {
|
feature_limits: {
|
||||||
|
|
|
@ -40,7 +40,7 @@ function transform<T>(
|
||||||
|
|
||||||
export default class Transformers {
|
export default class Transformers {
|
||||||
static toServer = ({ attributes }: FractalResponseData): Server => {
|
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 || {};
|
const { allocations, egg, nest, node, user, variables } = attributes.relationships || {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -56,7 +56,7 @@ export default class Transformers {
|
||||||
allocationId: attributes.allocation_id,
|
allocationId: attributes.allocation_id,
|
||||||
eggId: attributes.egg_id,
|
eggId: attributes.egg_id,
|
||||||
nestId: attributes.nest_id,
|
nestId: attributes.nest_id,
|
||||||
limits: { ...limits, oomDisabled: oom_disabled },
|
limits: { ...limits, oomKiller: oom_killer },
|
||||||
featureLimits: attributes.feature_limits,
|
featureLimits: attributes.feature_limits,
|
||||||
container: attributes.container,
|
container: attributes.container,
|
||||||
createdAt: new Date(attributes.created_at),
|
createdAt: new Date(attributes.created_at),
|
||||||
|
|
|
@ -195,9 +195,7 @@ export default () => {
|
||||||
io: 500,
|
io: 500,
|
||||||
cpu: 0,
|
cpu: 0,
|
||||||
threads: '',
|
threads: '',
|
||||||
// This value is inverted to have the switch be on when the
|
oomKiller: true,
|
||||||
// OOM Killer is enabled, rather than when disabled.
|
|
||||||
oomDisabled: false,
|
|
||||||
},
|
},
|
||||||
featureLimits: {
|
featureLimits: {
|
||||||
allocations: 1,
|
allocations: 1,
|
||||||
|
|
|
@ -23,10 +23,6 @@ export default () => {
|
||||||
const submit = (values: Values, { setSubmitting, setFieldValue }: FormikHelpers<Values>) => {
|
const submit = (values: Values, { setSubmitting, setFieldValue }: FormikHelpers<Values>) => {
|
||||||
clearFlashes('server');
|
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)
|
updateServer(server.id, values)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// setServer({ ...server, ...s });
|
// setServer({ ...server, ...s });
|
||||||
|
@ -58,7 +54,7 @@ export default () => {
|
||||||
threads: server.limits.threads || '',
|
threads: server.limits.threads || '',
|
||||||
// This value is inverted to have the switch be on when the
|
// This value is inverted to have the switch be on when the
|
||||||
// OOM Killer is enabled, rather than when disabled.
|
// OOM Killer is enabled, rather than when disabled.
|
||||||
oomDisabled: !server.limits.oomDisabled,
|
oomKiller: server.limits.oomKiller,
|
||||||
},
|
},
|
||||||
featureLimits: {
|
featureLimits: {
|
||||||
allocations: server.featureLimits.allocations,
|
allocations: server.featureLimits.allocations,
|
||||||
|
|
|
@ -60,7 +60,7 @@ export default () => {
|
||||||
/>
|
/>
|
||||||
<div css={tw`xl:col-span-2 bg-neutral-800 border border-neutral-900 shadow-inner p-4 rounded`}>
|
<div css={tw`xl:col-span-2 bg-neutral-800 border border-neutral-900 shadow-inner p-4 rounded`}>
|
||||||
<FormikSwitch
|
<FormikSwitch
|
||||||
name={'limits.oomDisabled'}
|
name={'limits.oomKiller'}
|
||||||
label={'Out of Memory Killer'}
|
label={'Out of Memory Killer'}
|
||||||
description={
|
description={
|
||||||
'Enabling the Out of Memory Killer may cause server processes to exit unexpectedly.'
|
'Enabling the Out of Memory Killer may cause server processes to exit unexpectedly.'
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import * as React from 'react';
|
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
||||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
|
||||||
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
|
||||||
import tw from 'twin.macro';
|
import tw from 'twin.macro';
|
||||||
|
|
||||||
|
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||||
|
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
||||||
|
|
||||||
type Props = Readonly<
|
type Props = Readonly<
|
||||||
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
||||||
title?: string;
|
title?: string;
|
||||||
borderColor?: string;
|
borderColor?: string;
|
||||||
showFlashes?: string | boolean;
|
showFlashes?: string | boolean;
|
||||||
|
|
Loading…
Reference in a new issue