Skip to content

Fix blueprint planner's validation of PlanningInput external networking#6599

Merged
jgallagher merged 4 commits into
mainfrom
john/planning-check-external-networking
Sep 18, 2024
Merged

Fix blueprint planner's validation of PlanningInput external networking#6599
jgallagher merged 4 commits into
mainfrom
john/planning-check-external-networking

Conversation

@jgallagher

@jgallagher jgallagher commented Sep 18, 2024

Copy link
Copy Markdown
Contributor

The "Check the planning input" block of code needs to consider all zones in the parent blueprint, including expunged zones. #6483 fixed the planner's ability to reuse external IPs from expunged zones, but accidentally made these checks incorrect, because it's certainly valid for the planning input to still have records for expunged zones. See #6581 (comment) for more context.

We also get to remove the somewhat-awkward update_network_resources_from_blueprint() test helper that was needed to make some tests pass (because we didn't realize the checks being performed here were wrong).

The "Check the planning input" block of code needs to consider _all_
zones in the parent blueprint, including expunged zones. #6483 fixed the
planner's ability to reuse external IPs from expunged zones, but
accidentally made these checks incorrect, because it's certainly valid
for the planning input to still have records for expunged zones. See
#6581 (comment)
for more context.

We also get to remove the somewhat-awkward
update_network_resources_from_blueprint() test helper that was needed in #6483
to make some tests pass (because we didn't realize the checks being
performed here were wrong).
@jgallagher jgallagher changed the title John/planning check external networking Fix blueprint planner's validation of PlanningInput external networking Sep 18, 2024
// Helper to validate that the system hasn't gone off the rails. There should
// never be any external networking resources in the planning input (which is
// derived from the contents of CRDB) that we don't know about from the parent
// blueprint.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I might say something explaining that this is possible, but means that our planning input has been invalidated, so the caller would be expected to take another lap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call; expanded in aca6f40

let zone_type = &z.zone_type;
match zone_type {
BlueprintZoneType::BoundaryNtp(ntp) => match ntp.nic.ip {
IpAddr::V4(ip) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just a suggestion: could we make the sets contain IpAddr? That'd consolidate it into fewer sets and eliminate the matching.

edit: I see that would make the code below a little more complicated. I'll leave it to you to decide if it's any better on net.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's an improvement; the code below just needs some cheap .into()s (9ae92dc). Thanks!

@plotnick plotnick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, thank you! Easy merge into #6581.

}

#[track_caller]
pub fn assert_planning_makes_no_changes(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome.

@jgallagher jgallagher enabled auto-merge (squash) September 18, 2024 19:49
@jgallagher jgallagher merged commit 40fc383 into main Sep 18, 2024
@jgallagher jgallagher deleted the john/planning-check-external-networking branch September 18, 2024 20:42
jgallagher added a commit that referenced this pull request Oct 2, 2024
…rds (#6742)

Recapping from the update sync:

* #6483 moved the code restored by this PR into a helper method
(`update_network_resources_from_blueprint()`), and also added calls to
that method to a handful of tests to make them pass
* In the external DNS work, we discovered that those tests should not
have needed that, and the reason they did was because of a different bug
* #6599 fixed that bug and removed
`update_network_resources_from_blueprint()` and all its callers, but
neglected to restore this code, meaning the `PlanningInput`s our tests
create from their initial system descriptions never had any external
networking records
hawkw pushed a commit that referenced this pull request Oct 2, 2024
…rds (#6742)

Recapping from the update sync:

* #6483 moved the code restored by this PR into a helper method
(`update_network_resources_from_blueprint()`), and also added calls to
that method to a handful of tests to make them pass
* In the external DNS work, we discovered that those tests should not
have needed that, and the reason they did was because of a different bug
* #6599 fixed that bug and removed
`update_network_resources_from_blueprint()` and all its callers, but
neglected to restore this code, meaning the `PlanningInput`s our tests
create from their initial system descriptions never had any external
networking records
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