bootstore type reorg PR 5/?: Split internal/external API types: Add ExternalImportExportPolicy#9910
bootstore type reorg PR 5/?: Split internal/external API types: Add ExternalImportExportPolicy#9910jgallagher wants to merge 7 commits intomainfrom
Conversation
As it evolved, #9570 made various changes to both the sled-agent types crate and the sled-agent API. As it landed, though, it made one versioning bump to sled-agent API (v20 - BGP) and two to the types crate (v20 - lockstep API, v21 - BGP). This squishes the latter two down to just one (v20 - BGP) for consistency with the API's versioning.
This is only used in the sled-agent -> Nexus RSS handoff request in the Nexus lockstep API.
…s-types` This also addresses some lingering TODOs from #9568 about `From` impls being defined in the wrong place per RFD 619.
|
Moving this to draft for now based on #9906 (comment). |
8805d4e to
ec816d8
Compare
Sorry for the rather vexing set of types here. I think part of the confusion here comes from the fact that when a user defines a BGP peer configuration, it references a higher level overall BGP configuration. These are distinct objects that the user creates and are also distinct tables in the database. When it comes time to send configure BGP through Maghemite, the type representation needs to be changed a bit based on how the data structures are hooked together in Maghemite. It's no longer a peer configuration referencing a top level BGP configuration by UUID, but BGP peer configs are tied to a top level configuration through ASNs. I'm also coming to think that putting BGP configuration and routes in the switch port settings object was a mistake. They should probably be their own top level things. I think part of the multiplicity we have in the data structures comes from the era in which these data structures landed about 3 years ago. Back then it was challenging to have common data structures across omicron without getting in a circular dependency mess with and an inability to generate openapi specs. This is all to say, yes I think it would be very worthwhile to reorganize and clean things up. There are parts of the BGP data structures that just aren't relevant at all. A rather large complexity down payment was made with the idea that breakout ports would soon become a thing, but that never happened and those interfaces just make the API and use of internal data structures much more confusing than it needs to be. |
ImportExportPolicywas defined inomicron_common::api::external, but was used in the external API, a few internal APIs, and serialized in the bootstore. This PR introducesExternalImportExportPolicy(external API only) and movesImportExportPolicy(the rest) intoomicron_common::api::internal::shared- future work in this chain of PRs will move it again (along with other serialized-in-the-bootstore types), but it has to land there for now.This makes no changes to any internal or external OpenAPI specs - it's only adjusting internal representations.
Part of #9801. Staged on top of #9909.
I'm a lot less sure of some of the types here than with previous PRs in this stack because I'm finding the various
BgpPeer{,Config}types pretty confusing. Some notes on types affected by this change:common::api::internal::shared::BgpPeerConfigis the type serialized in the bootstore and used in internal APIs, so it uses the now-internalImportExportPolicynexus_types::external_api::networking::BgpPeerlooks like the previous type (the internalBgpPeerConfig), but the fields aren't 1-to-1. This is an external type, so it usesExternalImportExportPolicy. (In principle this is fine, and is the point of this PR itself: the external types don't have to map 1-to-1 to internal types! But the names are quite confusing, largely because of the next two bullets.)nexus_types::external_api::networking::BgpPeerConfigalso exists but it's a container for a vec ofnexus_types::external_api::networking::BgpPeers and doesn't look anything at all like the internalBgpPeerConfigin the first bulletnexus/db-queries/src/db/datastore/switch_port.rsalso defines a public (!)BgpPeerConfigstruct that has many common fields with the internalBgpPeerConfigand the externalBgpPeer, but the types of the fields are database flavored (e.g.,SqlU32instead ofu32). This struct is included as a field in the publicSwitchPortSettingsCombinedResulttype defined in the same module that's consumed by a couple of Nexus background tasks. I'm not sure whether this should use the internal or externalImportExportPolicy. I originally had it using the external one (because of the way I thought it was used). In principle it seems like we should limit the external type to the external API, so in 924ca7e I changed it to use the internalImportExportPolicy, but feel free to tell me to revert that commit and go back to external. Weirdly (as you can see in the commit), this change did not affect any of the consumers of thisBgpPeerConfig, and rust-analyzer agrees that these fields are never read by anything. I don't know if they could be removed entirely, or if the fact that they're not being used is an oversight somewhere else.I'm a little tempted to throw up my hands and move
ImportExportPolicyback toomicron_commonand share one type everywhere, but that doesn't seem like the right direction - maybe it would be better to invest time in cleaning up the organization of these BGP types instead? Feedback very welcome.