Skip to content

Some Cleanup of the gRPC converter code in mgmt #532

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
merged 3 commits into from
May 28, 2025

Conversation

mvachhar
Copy link
Contributor

Started cleanup of the mgmt converter code.

I've added clippy checks and fixed issues, but not in a way that will change the interface.
I've removed all hard-coded constants
I've moved code to use Rust pattern matching instead of length checks + indexing for known-length vectors

There is still much more to do, but this is a good start at getting rid of some of the bigger issues.

@mvachhar mvachhar requested review from daniel-noland and Copilot May 28, 2025 02:23
@mvachhar mvachhar requested a review from a team as a code owner May 28, 2025 02:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR cleans up the gRPC converter code in the mgmt module, improves error handling, and replaces manual indexing with Rust’s pattern matching. Key changes include the addition of clippy checks, refactoring of CIDR and interface conversion logic using pattern matching, and improved enum conversion via try_from.

Comment on lines 180 to 181
.find(|vrf| vrf.name == "default")
.unwrap_or(&underlay.vrfs[0]);
.unwrap_or(&underlay.vrfs[0]); // FIXME(manish): This should be an error, preserving the original behavior for now

Copy link
Preview

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

Consider returning an error when no default VRF is found instead of defaulting to underlay.vrfs[0], as the FIXME comment indicates that this behavior should be changed.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@Fredi-raspall Fredi-raspall left a comment

Choose a reason for hiding this comment

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

LGTM @mvachhar !

@mvachhar mvachhar force-pushed the pr/smatov/advertise-networks branch 2 times, most recently from 3d5d341 to 6525541 Compare May 28, 2025 12:55
@mvachhar mvachhar force-pushed the pr/mvachhar/mgmt-cleanup branch 2 times, most recently from a51dc03 to 72c1dd2 Compare May 28, 2025 13:35
@mvachhar mvachhar force-pushed the pr/smatov/advertise-networks branch from 3a46e5f to a967446 Compare May 28, 2025 14:32
@mvachhar mvachhar force-pushed the pr/mvachhar/mgmt-cleanup branch from 72c1dd2 to 1659b57 Compare May 28, 2025 14:32
@mvachhar mvachhar modified the milestones: GW Preview, GW R1 May 28, 2025
@mvachhar mvachhar force-pushed the pr/smatov/advertise-networks branch from a967446 to 7572408 Compare May 28, 2025 15:05
@mvachhar mvachhar force-pushed the pr/mvachhar/mgmt-cleanup branch from 1659b57 to 537bf97 Compare May 28, 2025 15:06
@mvachhar mvachhar force-pushed the pr/smatov/advertise-networks branch from 7572408 to 1c50e2b Compare May 28, 2025 15:16
@mvachhar mvachhar force-pushed the pr/mvachhar/mgmt-cleanup branch from 537bf97 to 23829f0 Compare May 28, 2025 15:16
Base automatically changed from pr/smatov/advertise-networks to main May 28, 2025 16:25
mvachhar added 3 commits May 28, 2025 10:33
Silence clippy errors whose proper fix would require an interface change

Signed-off-by: Manish Vachharajani <[email protected]>
Rust pattern matching merges the length check with getting the entries.
By using pattern matching there can be no error where the length does
not match the dereference index leading to a runtime panic

Signed-off-by: Manish Vachharajani <[email protected]>
@mvachhar mvachhar force-pushed the pr/mvachhar/mgmt-cleanup branch from 23829f0 to 085e82a Compare May 28, 2025 16:33
@mvachhar mvachhar enabled auto-merge May 28, 2025 16:34
@mvachhar mvachhar added this pull request to the merge queue May 28, 2025
Merged via the queue into main with commit ad8b291 May 28, 2025
14 checks passed
@mvachhar mvachhar deleted the pr/mvachhar/mgmt-cleanup branch May 28, 2025 16:42
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.

2 participants