Skip to content

Commit 8b7536a

Browse files
committed
update API again for non-optional instance update keys
1 parent 60ca75e commit 8b7536a

File tree

9 files changed

+18
-29
lines changed

9 files changed

+18
-29
lines changed

OMICRON_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2d7479e297966b9fd486459d5865e8d958a78022
1+
af4a78e9cfcfeda9cf99156744c0efb913a9c1f8

app/api/__generated__/Api.ts

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/OMICRON_VERSION

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/validate.ts

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/util.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type {
1515
DiskState,
1616
Instance,
1717
InstanceState,
18-
InstanceUpdate,
1918
Measurement,
2019
SiloUtilization,
2120
Sled,
@@ -282,5 +281,3 @@ export function synthesizeData(
282281
}
283282

284283
export const OXQL_GROUP_BY_ERROR = 'Input tables to a `group_by` must be aligned'
285-
286-
export const instanceUpdateBody = (body: Required<InstanceUpdate>): InstanceUpdate => body

app/pages/project/instances/AutoRestartCard.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
useApiMutation,
1818
usePrefetchedApiQuery,
1919
} from '~/api'
20-
import { instanceUpdateBody } from '~/api/util'
2120
import { ListboxField } from '~/components/form/fields/ListboxField'
2221
import { useInstanceSelector } from '~/hooks/use-params'
2322
import { addToast } from '~/stores/toast'
@@ -76,18 +75,17 @@ export function AutoRestartCard() {
7675
instanceUpdate.mutate({
7776
path: { instance: instanceSelector.instance },
7877
query: { project: instanceSelector.project },
79-
body: instanceUpdateBody({
78+
body: {
8079
autoRestartPolicy: match(values.autoRestartPolicy)
8180
.with('default', () => null)
8281
.with('never', () => 'never' as const)
8382
.with('best_effort', () => 'best_effort' as const)
8483
.exhaustive(),
8584
ncpus: instance.ncpus,
8685
memory: instance.memory,
87-
// optional ones would be unset if we left them out
8886
cpuPlatform: instance.cpuPlatform || null,
8987
bootDisk: instance.bootDiskId || null,
90-
}),
88+
},
9189
})
9290
})
9391

app/pages/project/instances/InstancePage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
instanceAutoRestartingSoon,
2727
instanceCan,
2828
instanceTransitioning,
29-
instanceUpdateBody,
3029
} from '~/api/util'
3130
import { CopyIdItem } from '~/components/CopyIdItem'
3231
import { ExternalIps } from '~/components/ExternalIps'
@@ -342,14 +341,13 @@ export function ResizeInstanceModal({
342341
instanceUpdate.mutate({
343342
path: { instance: instance.name },
344343
query: { project },
345-
body: instanceUpdateBody({
344+
body: {
346345
ncpus,
347346
memory: memory * GiB,
348-
// these need to be passed in or they'll be unset
349347
bootDisk: instance.bootDiskId || null,
350348
cpuPlatform: instance.cpuPlatform || null,
351349
autoRestartPolicy: instance.autoRestartPolicy || null,
352-
}),
350+
},
353351
})
354352
})
355353
const formId = useId()

app/pages/project/instances/StorageTab.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
} from '@oxide/api'
2424
import { Storage24Icon } from '@oxide/design-system/icons/react'
2525

26-
import { instanceUpdateBody } from '~/api/util'
2726
import { HL } from '~/components/HL'
2827
import { DiskStateBadge } from '~/components/StateBadge'
2928
import { AttachDiskModalForm } from '~/forms/disk-attach'
@@ -164,14 +163,13 @@ export default function StorageTab() {
164163
doAction: () =>
165164
instanceUpdate({
166165
path: { instance: instance.id },
167-
body: instanceUpdateBody({
166+
body: {
168167
bootDisk: null,
169168
ncpus: instance.ncpus,
170169
memory: instance.memory,
171-
// optional ones would be unset if we left them out
172170
autoRestartPolicy: instance.autoRestartPolicy || null,
173171
cpuPlatform: instance.cpuPlatform || null,
174-
}),
172+
},
175173
}),
176174
errorTitle: 'Could not unset boot disk',
177175
modalTitle: 'Confirm unset boot disk',
@@ -230,14 +228,13 @@ export default function StorageTab() {
230228
doAction: () =>
231229
instanceUpdate({
232230
path: { instance: instance.id },
233-
body: instanceUpdateBody({
231+
body: {
234232
bootDisk: disk.id,
235233
ncpus: instance.ncpus,
236234
memory: instance.memory,
237-
// optional ones would be unset if we left them out
238235
autoRestartPolicy: instance.autoRestartPolicy || null,
239236
cpuPlatform: instance.cpuPlatform || null,
240-
}),
237+
},
241238
}),
242239
errorTitle: `Could not ${verb} boot disk`,
243240
modalTitle: `Confirm ${verb} boot disk`,

mock-api/msw/handlers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ export const handlers = makeHandlers({
641641

642642
// AUTO RESTART
643643

644-
// Undefined or missing is meaningful: it unsets the value
644+
// null is meaningful: it unsets the value
645645
instance.auto_restart_policy = body.auto_restart_policy
646646
instance.cpu_platform = body.cpu_platform
647647

@@ -652,7 +652,6 @@ export const handlers = makeHandlers({
652652

653653
// https://github.com/oxidecomputer/omicron/blob/0c6ab099e/nexus/db-queries/src/db/datastore/instance.rs#L228-L239
654654
instance.auto_restart_enabled = match(instance.auto_restart_policy)
655-
.with(undefined, () => true)
656655
.with(null, () => true)
657656
.with('best_effort', () => true)
658657
.with('never', () => false)

0 commit comments

Comments
 (0)