-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nexus-types] more validation for PlanningInput (#5644)
While reconciling the PlanningInput with the blueprint, I was a bit concerned about getting nonsensical inputs (e.g. multiple zones get the same IPs) and the system going haywire. In particular, I was concerned about the Serialize and Deserialize impls which were seemingly added for reconfigurator-cli. However, they were liabilities that didn't check for internal invariants. To address this, this PR introduces the notion of a `TriMap`. A `TriMap` is a 1:1:1 map which can be looked up by any one of three keys. Instead of storing just a regular map, the `PlanningInput` now stores a couple of `TriMap` instances via an intermediate `OmicronZoneNetworkResources` struct. A `TriMap` is implemented as a vector with three indexes. It's a pretty straightforward implementation, and I've also added property-based tests to ensure that a `TriMap` is always valid (including always deserializing to a valid structure). At the moment, a `TriMap` does not allow removing entries. If necessary, removals can be implemented by just marking the entry as dead and removing the keys from the indexes. This is fine for our use case, since `TriMap`s aren't long-lived. I've also factored out the omicron zone IP and NIC code into an `OmicronZoneNetworkResources` struct. In the future, we'll make the `BlueprintBuilder` use this struct, so that blueprints are validated whenever they're being mutated. We can also add this to the general code that validates blueprints.
- Loading branch information
1 parent
372d980
commit 949c6ab
Showing
13 changed files
with
982 additions
and
235 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Seeds for failure cases proptest has generated in the past. It is | ||
# automatically read and these particular cases re-run before any | ||
# novel cases are generated. | ||
# | ||
# It is recommended to check this file in to source control so that | ||
# everyone who runs the test benefits from these saved cases. | ||
cc bafcbc817cff65814a6f3233f1ef3d6c36f75c37ad35175d17d1c8484a734034 # shrinks to input = _ProptestOpsArgs { initial: {(0, '$', ""): "", (0, ' ', ""): ""}, ops: [] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.