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

Update InsertVpcSubnetQuery IP Block conflict detection logic #6880

Merged
merged 7 commits into from
Oct 18, 2024

Conversation

taspelund
Copy link
Contributor

Updates the logic to detect an IP Block collision when attempting to add a new VPC Subnet.
Initial approach was to call inet_contains_or_equals() twice (switching order of arguments to ensure the test is run bidirectionally), which did work.
However, Ben suggested we instead use && to do the testing since it works bidirectionally and reduces the amount of function/operator calls in the query.

The first commit in this series is an addition to the VPC Subnet insertion tests, which fail (correctly) without the subsequent commits that address the bad collision detection logic.

Fixes: #6870

@taspelund taspelund added bug Something that isn't working. networking Related to the networking. database Related to database access labels Oct 15, 2024
@taspelund taspelund self-assigned this Oct 15, 2024
Copy link
Collaborator

@bnaecker bnaecker left a comment

Choose a reason for hiding this comment

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

Thanks for catching this and writing the fix / regression! Looks good to me, just some small style nits. Thanks!

nexus/db-queries/src/db/queries/vpc_subnet.rs Outdated Show resolved Hide resolved
nexus/db-queries/src/db/queries/vpc_subnet.rs Outdated Show resolved Hide resolved
@taspelund taspelund force-pushed the trey/overlapping_vpc_subnet_query branch 2 times, most recently from 64150ba to 52e884f Compare October 18, 2024 17:53
taspelund and others added 7 commits October 18, 2024 14:49
Explicitly cover cases where VPC Subnets are being added with the same
network address but differing CIDR masks, e.g. 172.30.0.0/22 and
172.30.0.0/23.

Signed-off-by: Trey Aspelund <[email protected]>
Currently the error machinery emits v4 / v6 based on running an
additional check to see _which_ address field overlapped. We
need to update this check to work in both directions.
@taspelund taspelund force-pushed the trey/overlapping_vpc_subnet_query branch from 52e884f to c360e2b Compare October 18, 2024 20:49
@taspelund taspelund merged commit 27a4365 into main Oct 18, 2024
16 checks passed
@taspelund taspelund deleted the trey/overlapping_vpc_subnet_query branch October 18, 2024 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working. database Related to database access networking Related to the networking.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InsertVpcSubnetQuery only detects conflicts if CIDR mask is >= than the CIDR mask of an existing VPC Subnet
3 participants