Skip to content

[bgp-config] fix bgp_config_get by name#10609

Open
nicolaskagami wants to merge 2 commits into
mainfrom
nsk/bgp-config-get-by-name
Open

[bgp-config] fix bgp_config_get by name#10609
nicolaskagami wants to merge 2 commits into
mainfrom
nsk/bgp-config-get-by-name

Conversation

@nicolaskagami

@nicolaskagami nicolaskagami commented Jun 11, 2026

Copy link
Copy Markdown

Adds .filter(bgp_config::time_deleted.is_null()) to bgp_config_get, with some minor refactoring for readability. Also adds a regression test.

@nicolaskagami

Copy link
Copy Markdown
Author

While writing a unit test for the #10566, I noticed that bgp_config_get was failing to find the config by name, which led me to find #6471.

Apparently we don't expose GET:

Usage: oxide system networking bgp config [OPTIONS] <COMMAND>

Commands:
  create  Create BGP configuration
  delete  Delete BGP configuration
  list    List BGP configurations
  help    Print this message or the help of the given subcommand(s)

However, if we were to expose it or try to get by name internally we'd bump into the same problem as delete had with the full scans.

This change is fine unless we want GET to return entries with non-null time_deleted for some reason.

I also took the liberty of refactoring it a little.

@nicolaskagami nicolaskagami changed the title fix bgp_config_get by name [bgp-config] fix bgp_config_get by name Jun 11, 2026
@nicolaskagami nicolaskagami changed the title [bgp-config] fix bgp_config_get by name [bgp-config] fix bgp_config_get by name Jun 11, 2026
@nicolaskagami nicolaskagami marked this pull request as ready for review June 11, 2026 21:56
@nicolaskagami nicolaskagami self-assigned this Jun 12, 2026
@nicolaskagami nicolaskagami requested a review from jgallagher June 16, 2026 19:43

@jgallagher jgallagher 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.

LGTM, just a couple suggestions on a little more test fidelity.

.expect("create bgp config");

datastore
.bgp_config_get(&opctx, &NameOrId::Name(config_name.clone()))

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.

Could we add assertions that the properties of the config we get back match what we expect based on the create?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure. This would expand the test from a regression test into also checking GET functionality.

&BgpConfigSelector { name_or_id: NameOrId::Name(config_name) },
)
.await
.expect("delete bgp config by name");

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.

Could we add another bgp_config_get() after this delete and confirm we get the expected error (presumably a "not found")?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure. This would expand the test from a regression test into also checking GET functionality.

Same here but for DELETE

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