-
Notifications
You must be signed in to change notification settings - Fork 40
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
Network Operator BGP API improvements #6362
Conversation
Changes for #6081 with updated Oxide CLI:
|
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.
Thanks Levon! Comments follow. Will take this for a test drive shortly.
.await?; | ||
|
||
if !configs_with_asn.is_empty() { | ||
error!(opctx.log, "config for asn already exists"; "asn" => ?config.asn, "configs" => ?configs_with_asn); |
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.
maybe the name of this method should be bgp_config_create
instead of bgp_config_set
as the latter implies we'll update/overwrite the existing config if it exists.
if let Some(err) = err.take() { | ||
error!(opctx.log, "{msg}"; "error" => ?err); | ||
err | ||
} else { |
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.
Can you provide a comment on why non "takable" errors result in a 500?
match e { | ||
diesel::result::Error::NotFound => err | ||
.bail(Error::not_found_by_id( | ||
ResourceType::BgpConfig, |
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.
Should this be ResourceType::BgpAnnounceSet
?
diesel::result::Error::NotFound => err | ||
.bail(Error::not_found_by_name( | ||
ResourceType::BgpConfig, | ||
&name, |
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.
Same as above, should probably be ResourceType::BgpAnnounceSet
.
match e { | ||
diesel::result::Error::NotFound => err | ||
.bail(Error::not_found_by_id( | ||
ResourceType::BgpConfig, |
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.
ResourceType::BgpAnnounceSet
match e { | ||
diesel::result::Error::NotFound => err | ||
.bail(Error::not_found_by_name( | ||
ResourceType::BgpConfig, |
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.
ResourceType::BgpAnnounceSet
} | ||
})?; | ||
|
||
// if we're setting a port settings id (and therefore activating a configuration |
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.
Good catch! I guess this is one of the consequences of being able to build up arbitrary configs, but only have some of them active - we have to validate that anything that is being activated is valid against the rest of the active set.
Some more test output from Error un-squashing for bgp:
Not allowing multiple configs for a bgp asn:
|
// TODO: remove once per-switch-multi-asn support is added | ||
// Bail if an existing config for this ASN already exists. | ||
// This is a temporary measure until multi-asn-per-switch is supported. | ||
let configs_with_asn: Vec<BgpConfig> = dsl::bgp_config | ||
.filter(dsl::asn.eq(config.asn)) | ||
.filter(dsl::time_deleted.is_null()) | ||
.select(BgpConfig::as_select()) | ||
.load_async(&conn) | ||
.await?; |
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.
So I found something that needs to be changed here. Elsewhere in Nexus our logic relies on this code being idempotent, so I'm reworking this to allow and exact match to return Ok(config)
but otherwise bail with the error.
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.
This still might not be fixed, doing a bit more testing
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.
I think I have it sorted, it was another diesel-ism
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.
It's been happy for multiple a4x2
laps now, auto-merging
#6081
Refactored existing api to list bgp announce sets and added a new api to list announcements for an announce set
#6244 and #6245
Refactored bgp datastore methods to propagate additional error context as well as emit error types for the external API (404, 403, etc)
#6246
Two part fix:
#6349
Updated bgp datastore methods to always lookup the parent record (not just when the name needs to be resolved to a UUID). This guards us against situations where an invalid UUID is accidentally submitted.
Related
Resolving these issues for BGP