-
Notifications
You must be signed in to change notification settings - Fork 388
fix(connlib): failing proptest and overlapping routes not generated correctly #6722
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
Merged
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
thomaseizinger
approved these changes
Sep 17, 2024
Member
thomaseizinger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
a74a51e to
2837062
Compare
Co-authored-by: Thomas Eizinger <thomas@eizinger.io> Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
dc67338 to
828f626
Compare
Contributor
Author
|
@thomaseizinger another failing proptest test-case for this PR revealed another bug explained in the description. Please have another look :) |
thomaseizinger
approved these changes
Sep 18, 2024
Co-authored-by: Thomas Eizinger <thomas@eizinger.io> Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io> Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io> Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io> Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
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.
There were 3 problems currently on main, one on the tests and the actual bug.
Test problem
The routes were kept in a
BTreeSetthat when a new route was added it wasinserted into and when it was removed it wasremoved from using the address of the route.The problem is if there were overlapping route added twice in a row and then a single one of those resources is removed the test would believe the route no longer exists.
Test solution
Keep the routes in a
BTreeMapwhich maps the id to the ip and then we calculate the routes based on that combined with the default routes, that way we just remove the ID and the routes are kept in the correct expected state.Real bug
So fixing this revealed a similar bug in connlib, since we kept things in a similar struct,
active_cidr_resourcesusingIpNetworkTable.To fix this I re-calculate the whole table each time we add/remove a resource.
Note that this really doesn't properly fixes overlapping routes, this is just helpful to fix the test, to fix them we need #4789
Furthermore, fixing these issues revealed an additional problem, whenever we add an overlapping CIDR resource the old resource might be overridden, causing the connection to be lost, furthermore this happened in a non-deterministic(it's deterministic really but not explicit) way causing the tests to fail.
To fix this we always sort resources by ID(it's an arbitrary order to keep consistency with the proptests) and then we don't replace the routing for resources that already had a connection.
Sadly, to model this in the test I had to almost copy exactly how we calculate resources in connlib.
Fixes #6721