oxidecomputer / oxidecomputer/omicron

HostPhase2Status could use an enum when boot disk is unknown

Open
#10,504 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

To decide whether a sled is missing from inventory, we use the following method:

impl SledAgentUpdateStatus {
    /// Update status suitable for a given sled ID that isn't present in
    /// inventory.
    pub fn unknown(sled_id: SledUuid) -> Self {
        Self {
            sled_id,
            zones: IdOrdMap::new(),
            host_phase_2: HostPhase2Status {
                boot_disk: Err("unknown".to_string()),
                slot_a_version: TufRepoVersion::Unknown,
                slot_b_version: TufRepoVersion::Unknown,
            },
        }
    }
}

How we check the boot disk is a bit fragile due to string equality. It would be nice to return an enum variant.

Found in https://github.com/oxidecomputer/omicron/pull/10476#discussion_r3306051658

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with SledAgentUpdateStatus::unknown and the HostPhase2Status boot_disk field shown in the issue. Search for checks that compare the boot-disk error to the "unknown" string and trace their callers. Done means the unknown state is represented by an enum variant rather than fragile string equality, with affected behavior preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.