Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance auto restart #2644

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Instance auto restart #2644

wants to merge 3 commits into from

Conversation

benjaminleonard
Copy link
Contributor

@benjaminleonard benjaminleonard commented Jan 9, 2025

Fixes #2469

CleanShot 2025-01-09 at 12 03 09

  • Validate conditional rendering is correct
  • Automatically set autoRestartEnabled to match actual API behaviour
  • Add icon to design system
  • Write docs text
  • Add settings items help text
  • Show last auto restarted?

I'm sure someone will talk me down from the slow spinning icon when auto restart is enabled.

Copy link

vercel bot commented Jan 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Jan 9, 2025 5:37pm

// DocsPopoverPanel needed for enter animation
className="DocsPopoverPanel z-10 w-96 rounded-lg border bg-raise border-secondary elevation-2"
// popover-panel needed for enter animation
className="popover-panel z-10 w-96 rounded-lg border bg-raise border-secondary elevation-2"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This casing feels like a carry over from radix, and perhaps inconsistent?

className="max-w-none"
/>
<FormMeta label="Enabled" helpText="Help">
{instance.autoRestartEnabled ? 'True' : 'False'}{' '}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With our mock instance, it's possible for the policy to be set to never but autoRestartEnabled to be true. In case of the actual API it'll automatically set autoRestartEnabled to be false.

https://github.com/oxidecomputer/omicron/blob/f63ed095e744fb8d2383fda6799eb0b2d6dfbd3c/nexus/db-queries/src/db/datastore/instance.rs#L228C26-L239

We might want to modify the mock InstanceView handler to match this behaviour.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, definitely modify the mock handler and link to the API code in a comment.

body: {
ncpus: instance.ncpus,
memory: instance.memory,
bootDisk: instance.bootDiskId,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This strikes me as an awkward API design. Let's say the user just wants to update the autoRestartPolicy and does not include the bootDisk, it would then unset the instances boot disk. It also makes updating this in the CLI cumbersome.

Obviously it's outside of the scope of this PR, but thought I'd mention.

Copy link
Collaborator

@david-crespo david-crespo Jan 9, 2025

Choose a reason for hiding this comment

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

We've talked about this a lot on the API side (see oxidecomputer/omicron#6406). Most of our PUTs don't work this way, but it makes things simpler and more consistent if they do, so we are trying to move in this direction. Having to specify all the fields every time is of course a downside for clients. However, the problem with making the fields optional is that if leaving a field out doesn't unset, you still need to be able to unset one if you want, which means you have to have different semantics for "bootDisk not present" and bootDisk: null, and that's both confusing and not spec compliant.

In the CLI, we can deal with this by letting the user update one field but behind the scenes it supplies all the others.

Copy link
Contributor Author

@benjaminleonard benjaminleonard Jan 9, 2025

Choose a reason for hiding this comment

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

And I suppose having dedicated instance resize and update instance restart policy endpoints adds a bunch of extra code on the API? I was think less optionality and more something that would facilitate (CLI) instance auto-restart policy update.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, we don't really want to proliferate endpoints like that. My inclination would be to write that command by hand on the CLI side without it being a dedicated endpoint, or better yet come up with a pattern (a flag to instance update?) that lets you update one field while telling it to handle the rest for you.

)
}

const AutoRestartIcon12 = ({ className }: { className?: string }) => (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

todo: Add to design system and import from there

useEffect(() => {
const timer = setInterval(() => setNow(new Date()), 1000)
return () => clearInterval(timer)
}, [])
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll see about making this less scary

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

This looks lovely! I'm not particularly qualified to review the implementation of the frontend code, but I left a couple very minor suggestions on the text we display in the UI. Thanks for all your work on getting this exposed in the console, it looks great!

description="If unconfigured this instance uses the default auto-restart policy, which may or may not allow it to be restarted."
placeholder="Default"
items={[
{ value: '', label: 'None (Default)' },
Copy link
Member

Choose a reason for hiding this comment

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

I have a slight preference to just say "Default" here, rather than "None (Default)". I don't want to give the incorrect impression that not setting a policy is equivalent to disabling auto-restart when currently, we always default to "Best Effort".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good – I'd included None because it makes the API more intuitive to a user that has used the console, but default is clearer.

I suppose the argument for enforcing auto_restart_policy not null, and adding a default enum on the API is that it means the user is forced to include it at create time, when for most users they shouldn't need to touch this?

app/pages/project/instances/instance/tabs/SettingsTab.tsx Outdated Show resolved Hide resolved
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.

Expose instance auto-restart status in the console
3 participants