Check for cross-VPC firewall rules before DB write#10563
Open
david-crespo wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
I could see an argument that the check should go here since it's similar to this one, but it would require passing the DB model in so we could use the name. omicron/nexus/db-queries/src/db/datastore/vpc.rs Lines 661 to 671 in 4bb7276 |
sudomateo
approved these changes
Jun 9, 2026
sudomateo
left a comment
Contributor
There was a problem hiding this comment.
This looks good to me. Extracting the logic to a shared function is the cleanest way to move the error before the DB call without trying to solve the problem entirely. The test isn't exactly the process I followed when I ran into this, but it covers the same idea.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves #10561 but does not fully fix it, which would require cascading VPC renames down through all existing firewall rules.
The real problem here is that after you rename a VPC, any future updates to the firewall rules will fail if they neglect to update the VPC name in all targets and filters it appears in. This is especially a problem in the console, where you can only update one rule at a time. So even if you update the VPC name in that rule correctly, any other rules with the old name can still blow up the request. This PR does not fix this.
On top of that, the check for VPC name mismatches happens after we persist the rules to the DB. This is egregious, and it is what this PR fixes: we move the check for "cross-VPC rules" (mismatches between the VPC name and the VPC referenced in the rule) to before the DB write (technically we now do it both places to be safe).
A secondary accidental fix is that by erroring earlier, we avoid this
map_erradded in #10305 that turns the 400s into 500s. 500 is even worse than 400 here because it doesn't have the confusing message telling you that it's a cross-VPC issue.omicron/nexus/src/app/vpc.rs
Lines 258 to 270 in 955bc66