Skip to content

Commit 8207fdb

Browse files
committed
avoid unsetting optional fields in instance update
1 parent 3c0ee42 commit 8207fdb

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

app/pages/project/instances/AutoRestartCard.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { formatDistanceToNow } from 'date-fns'
1010
import { type ReactNode } from 'react'
1111
import { useForm } from 'react-hook-form'
12+
import * as R from 'remeda'
1213
import { match } from 'ts-pattern'
1314

1415
import {
@@ -76,9 +77,7 @@ export function AutoRestartCard() {
7677
path: { instance: instanceSelector.instance },
7778
query: { project: instanceSelector.project },
7879
body: {
79-
ncpus: instance.ncpus,
80-
memory: instance.memory,
81-
bootDisk: instance.bootDiskId,
80+
...R.pick(instance, ['ncpus', 'memory', 'bootDiskId', 'cpuPlatform']),
8281
autoRestartPolicy: match(values.autoRestartPolicy)
8382
.with('default', () => undefined)
8483
.with('never', () => 'never' as const)

app/pages/project/instances/InstancePage.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { filesize } from 'filesize'
99
import { useId, useState } from 'react'
1010
import { useForm } from 'react-hook-form'
1111
import { Link, useNavigate, type LoaderFunctionArgs } from 'react-router'
12+
import * as R from 'remeda'
1213

1314
import {
1415
apiQueryClient,
@@ -341,7 +342,12 @@ export function ResizeInstanceModal({
341342
instanceUpdate.mutate({
342343
path: { instance: instance.name },
343344
query: { project },
344-
body: { ncpus, memory: memory * GiB, bootDisk: instance.bootDiskId },
345+
body: {
346+
ncpus,
347+
memory: memory * GiB,
348+
// these need to be passed in or they'll be unset
349+
...R.pick(instance, ['bootDiskId', 'cpuPlatform', 'autoRestartPolicy']),
350+
},
345351
})
346352
})
347353
const formId = useId()

app/pages/project/instances/StorageTab.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,13 @@ export default function StorageTab() {
165165
path: { instance: instance.id },
166166
body: {
167167
bootDisk: undefined,
168-
ncpus: instance.ncpus,
169-
memory: instance.memory,
170-
// this would get unset if we left it out
171-
autoRestartPolicy: instance.autoRestartPolicy,
168+
...R.pick(instance, [
169+
'ncpus',
170+
'memory',
171+
// these would be unset if we left them out
172+
'autoRestartPolicy',
173+
'cpuPlatform',
174+
]),
172175
},
173176
}),
174177
errorTitle: 'Could not unset boot disk',
@@ -229,10 +232,13 @@ export default function StorageTab() {
229232
path: { instance: instance.id },
230233
body: {
231234
bootDisk: disk.id,
232-
ncpus: instance.ncpus,
233-
memory: instance.memory,
234-
// this would get unset if we left it out
235-
autoRestartPolicy: instance.autoRestartPolicy,
235+
...R.pick(instance, [
236+
'ncpus',
237+
'memory',
238+
// these would be unset if we left them out
239+
'autoRestartPolicy',
240+
'cpuPlatform',
241+
]),
236242
},
237243
}),
238244
errorTitle: `Could not ${verb} boot disk`,

0 commit comments

Comments
 (0)