Skip to content

bootstore type reorg PR 5/?: Split internal/external API types: Add ExternalImportExportPolicy#9910

Draft
jgallagher wants to merge 7 commits intomainfrom
john/shadow-external-types-3
Draft

bootstore type reorg PR 5/?: Split internal/external API types: Add ExternalImportExportPolicy#9910
jgallagher wants to merge 7 commits intomainfrom
john/shadow-external-types-3

Conversation

@jgallagher
Copy link
Contributor

ImportExportPolicy was defined in omicron_common::api::external, but was used in the external API, a few internal APIs, and serialized in the bootstore. This PR introduces ExternalImportExportPolicy (external API only) and moves ImportExportPolicy (the rest) into omicron_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::BgpPeerConfig is the type serialized in the bootstore and used in internal APIs, so it uses the now-internal ImportExportPolicy
  • nexus_types::external_api::networking::BgpPeer looks like the previous type (the internal BgpPeerConfig), but the fields aren't 1-to-1. This is an external type, so it uses ExternalImportExportPolicy. (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::BgpPeerConfig also exists but it's a container for a vec of nexus_types::external_api::networking::BgpPeers and doesn't look anything at all like the internal BgpPeerConfig in the first bullet
  • nexus/db-queries/src/db/datastore/switch_port.rs also defines a public (!) BgpPeerConfig struct that has many common fields with the internal BgpPeerConfig and the external BgpPeer, but the types of the fields are database flavored (e.g., SqlU32 instead of u32). This struct is included as a field in the public SwitchPortSettingsCombinedResult type 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 external ImportExportPolicy. 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 internal ImportExportPolicy, 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 this BgpPeerConfig, 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 ImportExportPolicy back to omicron_common and 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.

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.
@jgallagher
Copy link
Contributor Author

Moving this to draft for now based on #9906 (comment).

@jgallagher jgallagher force-pushed the john/shadow-external-types-2 branch from 8805d4e to ec816d8 Compare February 24, 2026 18:11
Base automatically changed from john/shadow-external-types-2 to main February 24, 2026 21:21
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.

1 participant