Skip to content

Commit a030b9e

Browse files
authored
Boot order (#2464)
* bump API for boot disk changes * implement instance update endpoint * show boot disk with badge in table * add row actions * instance create works good * point at the actual omicron PR * split instance disks into two tables * move the disk buttons into the table headers * fix one our most pointless e2es * assert about boot disks after instance create * add e2e test for instance create with more disks, test disk create * move the buttons back under the tables * take the button out, always disable detach for boot disk * split frankenstein actions array into two, make e2e tests pass * update omicron to latest commit on PR, fix breakage thereby introduced * mock update errors out if boot disk is not attached * update to a commit on omicron main * cite omicron source for logic about when you can set a boot disk * test for changing boot disk * ixi's feedback, clean up mock API logic * moderately deranged boot disk empty state copy * tweak empty state copy and assert about it in e2e test * clean up copy TODOs in confirm modals * bump API to latest dogfood version (only doc comment changes) * rename disks to otherDisks, existing disk test looks at boot vs. other
1 parent dec4849 commit a030b9e

File tree

16 files changed

+663
-137
lines changed

16 files changed

+663
-137
lines changed

OMICRON_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d2e3f344e82fd7a1f45a39a9d1f867f9238d171d
1+
c50cf019cd9be35f98266a7f4acacab0236b3a3d

app/api/__generated__/Api.ts

+80-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/OMICRON_VERSION

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/msw-handlers.ts

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/validate.ts

+34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/util.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@ export const genName = (...parts: [string, ...string[]]) => {
9090
}
9191

9292
const instanceActions: Record<string, InstanceState[]> = {
93+
// NoVmm maps to to Stopped:
94+
// https://github.com/oxidecomputer/omicron/blob/6dd9802/nexus/db-model/src/instance_state.rs#L55
95+
9396
// https://github.com/oxidecomputer/omicron/blob/0496637/nexus/src/app/instance.rs#L2064
9497
start: ['stopped', 'failed'],
9598

9699
// https://github.com/oxidecomputer/omicron/blob/6dd9802/nexus/db-queries/src/db/datastore/instance.rs#L865
97100
delete: ['stopped', 'failed'],
98101

102+
// https://github.com/oxidecomputer/omicron/blob/3093818/nexus/db-queries/src/db/datastore/instance.rs#L1030-L1043
103+
update: ['stopped', 'failed', 'creating'],
104+
99105
// reboot and stop are kind of weird!
100106
// https://github.com/oxidecomputer/omicron/blob/6dd9802/nexus/src/app/instance.rs#L790-L798
101107
// https://github.com/oxidecomputer/propolis/blob/b278193/bin/propolis-server/src/lib/vm/request_queue.rs
@@ -104,9 +110,6 @@ const instanceActions: Record<string, InstanceState[]> = {
104110
// stopping a failed disk: https://github.com/oxidecomputer/omicron/blob/f0b804818b898bebdb317ac2b000618944c02457/nexus/src/app/instance.rs#L818-L830
105111
stop: ['running', 'starting', 'rebooting', 'failed'],
106112

107-
// NoVmm maps to to Stopped:
108-
// https://github.com/oxidecomputer/omicron/blob/6dd9802/nexus/db-model/src/instance_state.rs#L55
109-
110113
// https://github.com/oxidecomputer/omicron/blob/6dd9802/nexus/db-queries/src/db/datastore/disk.rs#L323-L327
111114
detachDisk: ['creating', 'stopped', 'failed'],
112115
// only Creating and NoVmm
@@ -149,6 +152,8 @@ const diskActions: Record<string, DiskState['state'][]> = {
149152
attach: ['creating', 'detached'],
150153
// https://github.com/oxidecomputer/omicron/blob/6dd9802/nexus/db-queries/src/db/datastore/disk.rs#L313-L314
151154
detach: ['attached'],
155+
// https://github.com/oxidecomputer/omicron/blob/3093818/nexus/db-queries/src/db/datastore/instance.rs#L1077-L1081
156+
setAsBootDisk: ['attached'],
152157
}
153158

154159
export const diskCan = R.mapValues(diskActions, (states) => {

app/components/form/fields/DisksTableField.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { CreateDiskSideModalForm } from '~/forms/disk-create'
1515
import type { InstanceCreateInput } from '~/forms/instance-create'
1616
import { Badge } from '~/ui/lib/Badge'
1717
import { Button } from '~/ui/lib/Button'
18-
import { FieldLabel } from '~/ui/lib/FieldLabel'
1918
import * as MiniTable from '~/ui/lib/MiniTable'
2019
import { bytesToGiB } from '~/util/units'
2120

@@ -39,14 +38,13 @@ export function DisksTableField({
3938

4039
const {
4140
field: { value: items, onChange },
42-
} = useController({ control, name: 'disks' })
41+
} = useController({ control, name: 'otherDisks' })
4342

4443
return (
4544
<>
4645
<div className="max-w-lg">
47-
<FieldLabel id="new-disks-label">{/* this was empty */}</FieldLabel>
4846
{!!items.length && (
49-
<MiniTable.Table className="mb-4">
47+
<MiniTable.Table className="mb-4" aria-label="Disks">
5048
<MiniTable.Header>
5149
<MiniTable.HeadCell>Name</MiniTable.HeadCell>
5250
<MiniTable.HeadCell>Type</MiniTable.HeadCell>
@@ -68,7 +66,7 @@ export function DisksTableField({
6866
</MiniTable.Cell>
6967
<MiniTable.Cell>
7068
{item.type === 'attach' ? (
71-
'-'
69+
''
7270
) : (
7371
<>
7472
<span>{bytesToGiB(item.size)}</span>

app/forms/instance-create.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export type InstanceCreateInput = Assign<
103103
SetRequired<InstanceCreate, 'networkInterfaces'>,
104104
{
105105
presetId: (typeof PRESETS)[number]['id']
106-
disks: DiskTableItem[]
106+
otherDisks: DiskTableItem[]
107107
bootDiskName: string
108108
bootDiskSize: number
109109

@@ -139,7 +139,7 @@ const baseDefaultValues: InstanceCreateInput = {
139139
projectImageSource: '',
140140
diskSource: '',
141141

142-
disks: [],
142+
otherDisks: [],
143143
networkInterfaces: { type: 'default' },
144144

145145
sshPublicKeys: [],
@@ -316,7 +316,8 @@ export function CreateInstanceForm() {
316316
description: values.description,
317317
memory: instance.memory * GiB,
318318
ncpus: instance.ncpus,
319-
disks: [bootDisk, ...values.disks],
319+
disks: values.otherDisks,
320+
bootDisk,
320321
externalIps: values.externalIps,
321322
start: values.start,
322323
networkInterfaces: values.networkInterfaces,

0 commit comments

Comments
 (0)