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

Remove ability to generate a Blueprint from an inventory collection #5583

Merged
merged 10 commits into from
Apr 20, 2024

Conversation

jgallagher
Copy link
Contributor

We want to add information in blueprints, particularly BlueprintZoneConfig and BlueprintZoneType, that is not present in the sled-agent types OmicronZoneConfig and OmicronZoneType. Today on main conversion between those types is bidirectional. As we add to blueprints, we will continue to be able to convert a BlueprintZoneConfig into an OmicronZoneConfig, but the opposite direction will become more and more difficult as callers need to provide the additional information required for blueprints.

We have enough users of the inventory -> blueprint direction that it's quite painful to try to add to blueprints, so this PR attempts to knock out one of the more common uses: converting an inventory collection into a blueprint via BlueprintBuilder::build_initial_from_collection(). This method is removed, and all the remaining changes are fallout from that. Most uses of this have been replaced by either the blueprint produced by ExampleSystem or the new BlueprintBuilder::build_empty_with_sleds() helper for constructing an empty blueprint. One test needed the full blueprint-from-inventory, so that one actually gained a new use of converting OmicronZoneConfig -> BlueprintZoneConfig. (Not ideal, but fine for now!)

.blueprint_disks
.values()
.map(|c| c.disks.len())
.sum::<usize>()
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 assertion change is, I believe, a fix for a test that was passing incorrectly. blueprint_disks is a BTreeMap<SledUuid, PhysicalDisksConfig>, which means blueprint_disks.len() reported "for how many sleds do we have a PhysicalDisksConfig?", not "how many disks are in the blueprint" as the check seemed to mean. I think this was passing purely by coincidence:

  • blueprint1.blueprint_disks was empty, because a blueprint created from an inventory collection didn't populate it at all
  • new_sled_zpools was 4, because we added 4 disks
  • blueprint2.blueprint_disks.len() was 4, because there are 4 sleds in blueprint2, and going through the builder populates blueprint_disks

so we were previously passing because 0 + 4 == 4, even though the units of these values made the comparison nonsensical.

@jgallagher jgallagher merged commit 84e9c27 into main Apr 20, 2024
21 checks passed
@jgallagher jgallagher deleted the john/remove-blueprint-from-collection branch April 20, 2024 16:47
jgallagher added a commit that referenced this pull request Apr 22, 2024
…5584)

This builds on #5583; see it for rationale.

We remove half of the remaining callers that want to convert
`OmicronZoneConfig` into `BlueprintZoneConfig`:

* `nexus-test-utils`'s quasi-RSS: This now works in terms of
`BlueprintZoneConfig`, and converts down to `OmicronZoneConfig` when
necessary. This is the kind of transformation we'd like to make in real
RSS, too, although it will be more complex there.
* One unit test in `nexus-reconfigurator-execution`: replaced using the
`representative()` collection (which includes a collection from a live
system, but no blueprint) with the `example()` system (which produces
both a collection and a matching blueprint).
* Blueprint diffing - the types for the "before" side (which can be a
collection or a blueprint) are now wrapped in two-variant enums, with
some helpers for comparisons, instead of converting the collection to a
blueprint.

The remaining users of this conversion direction are the most difficult,
but at least we're down to three:

* `nexus-db-model` does this conversion to use some shared database
serialization logic. This will necessarily change when we add to
blueprints, since the serialization logic won't be shared anymore (or at
least not _as_ shared).
* RSS; see note above. We might be able to handle this like we did
`nexus-test-utils`; I'll see when it becomes necessary.
* The DNS test that uses data from a live system.

Even if the last two have to keep this conversion direction for now
(which will become more complex as data is added), at least it's only
two! That should be manageable even if the process gets a little messy.
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.

2 participants