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,
|
||||
'io' => $model->io,
|
||||
'memory' => $model->memory,
|
||||
'oom_disabled' => $model->oom_disabled,
|
||||
'oom_killer' => !$model->oom_disabled,
|
||||
'swap' => $model->swap,
|
||||
'threads' => $model->threads,
|
||||
],
|
||||
|
|
|
@ -18,7 +18,7 @@ interface ServerLimits {
|
|||
io: number;
|
||||
cpu: number;
|
||||
threads: string | null;
|
||||
oomDisabled: boolean;
|
||||
oomKiller: boolean;
|
||||
}
|
||||
|
||||
export interface ServerVariable extends EggVariable {
|
||||
|
|
|
@ -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<Server>
|
|||
memory: r.limits.memory,
|
||||
swap: r.limits.swap,
|
||||
threads: r.limits.threads,
|
||||
oom_killer: r.limits.oomDisabled,
|
||||
oom_killer: r.limits.oomKiller,
|
||||
},
|
||||
|
||||
feature_limits: {
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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<Values>, 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: {
|
||||
|
|
|
@ -40,7 +40,7 @@ function transform<T>(
|
|||
|
||||
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),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -23,10 +23,6 @@ export default () => {
|
|||
const submit = (values: Values, { setSubmitting, setFieldValue }: FormikHelpers<Values>) => {
|
||||
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,
|
||||
|
|
|
@ -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`}>
|
||||
<FormikSwitch
|
||||
name={'limits.oomDisabled'}
|
||||
name={'limits.oomKiller'}
|
||||
label={'Out of Memory Killer'}
|
||||
description={
|
||||
'Enabling the Out of Memory Killer may cause server processes to exit unexpectedly.'
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import * as React from 'react';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
||||
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
||||
import tw from 'twin.macro';
|
||||
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
||||
|
||||
type Props = Readonly<
|
||||
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
||||
DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
||||
title?: string;
|
||||
borderColor?: string;
|
||||
showFlashes?: string | boolean;
|
||||
|
|
Loading…
Reference in a new issue