Skip to content

Conversation

@david-crespo
Copy link
Collaborator

See oxidecomputer/omicron#8728. The API change is small and the default value means we don't actually have to change anything in the console yet except avoiding unsetting it in existing instance update calls. When we do add it to the UI, for create it would probably be down at the bottom of the form:

image

We'd also have to display the current value on instance detail and give a way to change it.

@vercel
Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
console Ready Ready Preview Sep 19, 2025 8:32pm

@david-crespo david-crespo changed the title Bump api for cpu types Instance CPU types Sep 18, 2025
bootDisk: instance.bootDiskId,
cpuPlatform: instance.cpuPlatform,
autoRestartPolicy: instance.autoRestartPolicy,
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure the fact that this was missing autoRestartPolicy was a bug.

@david-crespo
Copy link
Collaborator Author

@iximeow do we want full UI support for the next release or can it wait until v18? Not that it's a big lift, really.

@iximeow
Copy link
Member

iximeow commented Sep 18, 2025

my 2c is that UI support isn't really helpful until someone's got Cosmos to work with, so I wouldn't sweat v17 for this

@david-crespo david-crespo marked this pull request as ready for review September 18, 2025 13:49
@david-crespo
Copy link
Collaborator Author

david-crespo commented Sep 18, 2025

I might make a helper with a stricter type than the API that can help us avoid forgetting a key. Another thing we might consider is removing optional from those keys on the API side while keeping them nullable, if that’s possible.

david-crespo added a commit to oxidecomputer/omicron that referenced this pull request Sep 18, 2025
…e required to be present (#9046)

Optional fields on a request body can be left out completely from the
JSON. In the case of instance update (and probably many other endpoints)
this is a problem because passing `null` and passing nothing have the
same effect, namely unsetting that field if it is already set in the DB.
And because the fields are optional, the generated client types do not
enforce that they are present (at least when creating the JSON by hand
and also in TypeScript, which distinguishes between optional and
nullable at the type level). It is easy to do this by accident: while
working on [this](oxidecomputer/console#2900), I
[discovered a
bug](oxidecomputer/console#2900 (comment))
in the console where we accidentally unset the auto restart policy on an
instance when you resize an instance.

This PR changes `Option` to `Nullable`, which I added in #8214 to fix
this problem: `null` remains a valid value, but the client is no longer
allowed to leave that field out of the body. If we don't want to do
this, I can live with it because in the console, I have [made a
helper](oxidecomputer/console@60ca75e)
that enforces that all fields are explicitly present. But I do think the
status quo is very error-prone.


https://github.com/oxidecomputer/omicron/blob/c6989117c72ecf88d4e3dc8a597d9fe703152a93/common/src/api/external/mod.rs#L3564-L3570
@david-crespo
Copy link
Collaborator Author

I might make a helper with a stricter type than the API that can help us avoid forgetting a key. Another thing we might consider is removing optional from those keys on the API side while keeping them nullable, if that’s possible.

I created this in 60ca75e and then removed it in 60ca75e because I did it on the API side.

Currently, the global default auto-restart policy is "best-effort", so instances with `null` auto-restart policies will be automatically restarted. However, in the future, the default policy may be configurable through other mechanisms, such as on a per-project basis. In that case, any configured default policy will be used if this is `null`. */
autoRestartPolicy?: InstanceAutoRestartPolicy | null
autoRestartPolicy: InstanceAutoRestartPolicy | null
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer optional

@david-crespo david-crespo enabled auto-merge (squash) September 19, 2025 20:36
@david-crespo david-crespo merged commit 36e415c into main Sep 19, 2025
7 checks passed
@david-crespo david-crespo deleted the bump-api-cpu-types branch September 19, 2025 20:37
charliepark pushed a commit to oxidecomputer/omicron that referenced this pull request Sep 19, 2025
…e required to be present (#9046)

Optional fields on a request body can be left out completely from the
JSON. In the case of instance update (and probably many other endpoints)
this is a problem because passing `null` and passing nothing have the
same effect, namely unsetting that field if it is already set in the DB.
And because the fields are optional, the generated client types do not
enforce that they are present (at least when creating the JSON by hand
and also in TypeScript, which distinguishes between optional and
nullable at the type level). It is easy to do this by accident: while
working on [this](oxidecomputer/console#2900), I
[discovered a
bug](oxidecomputer/console#2900 (comment))
in the console where we accidentally unset the auto restart policy on an
instance when you resize an instance.

This PR changes `Option` to `Nullable`, which I added in #8214 to fix
this problem: `null` remains a valid value, but the client is no longer
allowed to leave that field out of the body. If we don't want to do
this, I can live with it because in the console, I have [made a
helper](oxidecomputer/console@60ca75e)
that enforces that all fields are explicitly present. But I do think the
status quo is very error-prone.


https://github.com/oxidecomputer/omicron/blob/c6989117c72ecf88d4e3dc8a597d9fe703152a93/common/src/api/external/mod.rs#L3564-L3570
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants