Skip to content

Conversation

jgallagher
Copy link
Contributor

This is mostly moving code around; specifically, BlueprintDisksEditor is now in its own module. The non-"moving code around" changes are:

  • The API stile is more imperative.
  • Generation 1 for OmicronPhysicalDisksConfig is now only the empty set of disks; if there are disks present, that will be at least generation 2. This caused some expectorate churn but seems probably fine? It matches how OmicronZonesConfig generations are numbered.

Changes the API style to be more imperative. One behavioral change is
that "generation 1" is only ever the set of empty disks; if any disks
are added, that becomes "generation 2". This is consistent with how we
define the OmicronZonesConfig generation, but is a change from what's on
main.
Some(&config.disks)
}

pub fn build(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we include some docs about why we're passing sled_ids again here?

(e.g., why are we passing this here, when BlueprintDisksEditor is already taking a map of sleds as input?)

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Sean that a comment is a good idea.

To check my understanding, the sleds we take in the constructor are all from the parent blueprint, but these sleds are the InService sleds from the PlanningInput which may be different. This allows us to add a DiskConfig::Empty for any new sleds, and also to ignore sleds that are no longer in service but may have configurations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the last bit is the most relevant one: we do indeed pass only InService sleds, so in practice the incoming sled IDs here allow us to drop sleds that were present in the parent blueprint but are no longer in service.

TBH this is confusing, there were related bits that confused Sean and me in the original datasets PR (#6229 (comment)). We'll have to address this when we start squishing these maps back together, at which point the sled IDs here probably go away?

I'll add the comment though!

parent_changed_set: &'a mut BTreeSet<SledUuid>,
}

impl Drop for SledDisksEditor<'_> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Neat, so the mutable borrows here require that SledDisksEditor is dropped before BlueprintDisksEditor::build gets called, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct.

You could always leak or mem::forget() a SledDisksEditor, but at that point you get what you deserve, I think? The alternative would be for sled_disks_editor to take an FnOnce(&mut SledDisksEditor), but that's much more awkward from a caller's point of view. It seems fine to say "if you leak a SledDisksEditor your edits won't be fully reflected".

Copy link
Contributor

@andrewjstone andrewjstone left a comment

Choose a reason for hiding this comment

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

Looks great.

Some(&config.disks)
}

pub fn build(
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Sean that a comment is a good idea.

To check my understanding, the sleds we take in the constructor are all from the parent blueprint, but these sleds are the InService sleds from the PlanningInput which may be different. This allows us to add a DiskConfig::Empty for any new sleds, and also to ignore sleds that are no longer in service but may have configurations.

@jgallagher jgallagher merged commit a73bc0d into main Nov 20, 2024
16 checks passed
@jgallagher jgallagher deleted the john/reconfigurator-storage-1 branch November 20, 2024 18:52
jgallagher added a commit that referenced this pull request Nov 20, 2024
…setsEditor` to its own module (#7104)

Followup to (and staged on top of) #7103, and makes similar changes for
datasets as that PR did for disks.

Much more expectorate churn in this one, but it should all still be
stable.
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