Skip to content

Commit 36e415c

Browse files
authored
Instance CPU types (#2900)
* bump api for cpu types * avoid unsetting optional fields in instance update * helper to avoid instance update mistakes * update API again for non-optional instance update keys
1 parent e0efddf commit 36e415c

File tree

8 files changed

+75
-19
lines changed

8 files changed

+75
-19
lines changed

OMICRON_VERSION

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

app/api/__generated__/Api.ts

Lines changed: 29 additions & 3 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: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/pages/project/instances/AutoRestartCard.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@ export function AutoRestartCard() {
7676
path: { instance: instanceSelector.instance },
7777
query: { project: instanceSelector.project },
7878
body: {
79-
ncpus: instance.ncpus,
80-
memory: instance.memory,
81-
bootDisk: instance.bootDiskId,
8279
autoRestartPolicy: match(values.autoRestartPolicy)
83-
.with('default', () => undefined)
80+
.with('default', () => null)
8481
.with('never', () => 'never' as const)
8582
.with('best_effort', () => 'best_effort' as const)
8683
.exhaustive(),
84+
ncpus: instance.ncpus,
85+
memory: instance.memory,
86+
cpuPlatform: instance.cpuPlatform || null,
87+
bootDisk: instance.bootDiskId || null,
8788
},
8889
})
8990
})

app/pages/project/instances/InstancePage.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,13 @@ export function ResizeInstanceModal({
341341
instanceUpdate.mutate({
342342
path: { instance: instance.name },
343343
query: { project },
344-
body: { ncpus, memory: memory * GiB, bootDisk: instance.bootDiskId },
344+
body: {
345+
ncpus,
346+
memory: memory * GiB,
347+
bootDisk: instance.bootDiskId || null,
348+
cpuPlatform: instance.cpuPlatform || null,
349+
autoRestartPolicy: instance.autoRestartPolicy || null,
350+
},
345351
})
346352
})
347353
const formId = useId()

app/pages/project/instances/StorageTab.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ export default function StorageTab() {
164164
instanceUpdate({
165165
path: { instance: instance.id },
166166
body: {
167-
bootDisk: undefined,
167+
bootDisk: null,
168168
ncpus: instance.ncpus,
169169
memory: instance.memory,
170-
// this would get unset if we left it out
171-
autoRestartPolicy: instance.autoRestartPolicy,
170+
autoRestartPolicy: instance.autoRestartPolicy || null,
171+
cpuPlatform: instance.cpuPlatform || null,
172172
},
173173
}),
174174
errorTitle: 'Could not unset boot disk',
@@ -205,6 +205,7 @@ export default function StorageTab() {
205205
instance.autoRestartPolicy,
206206
instance.ncpus,
207207
instance.memory,
208+
instance.cpuPlatform,
208209
getSnapshotAction,
209210
]
210211
)
@@ -231,8 +232,8 @@ export default function StorageTab() {
231232
bootDisk: disk.id,
232233
ncpus: instance.ncpus,
233234
memory: instance.memory,
234-
// this would get unset if we left it out
235-
autoRestartPolicy: instance.autoRestartPolicy,
235+
autoRestartPolicy: instance.autoRestartPolicy || null,
236+
cpuPlatform: instance.cpuPlatform || null,
236237
},
237238
}),
238239
errorTitle: `Could not ${verb} boot disk`,
@@ -283,6 +284,7 @@ export default function StorageTab() {
283284
instance.autoRestartPolicy,
284285
instance.ncpus,
285286
instance.memory,
287+
instance.cpuPlatform,
286288
getSnapshotAction,
287289
bootDisks,
288290
]

mock-api/msw/handlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,9 @@ 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
646+
instance.cpu_platform = body.cpu_platform
646647

647648
// We depart here from nexus in that nexus does both of the following
648649
// calculations at view time (when converting model to view). We can't
@@ -651,7 +652,6 @@ export const handlers = makeHandlers({
651652

652653
// https://github.com/oxidecomputer/omicron/blob/0c6ab099e/nexus/db-queries/src/db/datastore/instance.rs#L228-L239
653654
instance.auto_restart_enabled = match(instance.auto_restart_policy)
654-
.with(undefined, () => true)
655655
.with(null, () => true)
656656
.with('best_effort', () => true)
657657
.with('never', () => false)

0 commit comments

Comments
 (0)