oxidecomputer / oxidecomputer/omicron
instance creation & the create saga should avoid refetching DB records where possible
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 572
- Forks
- 97
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 96
Description
When Nexus creates an instance in a project, it runs the creation saga, then refetches the instance's record from CRDB and returns the refetched record. But once the instance has moved out of the "Creating" state, it can be stopped and deleted, which could cause instance creation to 404, as described in this comment:
The create saga itself also refetches records in a mildly dangerous way. If the saga creates an instance but doesn't start it, the saga will have a step that tries to move the instance's state to "Stopped" unconditionally. This is incorrect if the step gets replayed, as described in this comment:
These cases can be fixed by taking advantage of the fact that nexus_db_model::Instances are (now) serializable (at one point they weren't), such that a serialized instance description can be passed from saga step to saga step (or provided as saga output).
This may help address some cases of #1536 (if we don't do a DB fetch, we can't use the wrong key!), but the two issues are distinct and this one won't totally address that one.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked sections in nexus/src/app/instance.rs (lines 180-224) and nexus/src/app/sagas/instance_create.rs (lines 1340-1364). Trace the instance creation response and saga steps to identify the refetches and replay behavior. Done means serialized Instance records are reused where possible, avoiding the described 404 and unconditional state transition cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100