-
Notifications
You must be signed in to change notification settings - Fork 83
Multirack: Wicketd API for cluster join config #10465
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
Open
andrewjstone
wants to merge
6
commits into
main
Choose a base branch
from
wicket-multirack-join-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d6e2697
Multirack: Wicketd API for cluster join config
andrewjstone 83e615f
openapi
andrewjstone bb42a84
Add support for auto ddm config
andrewjstone bc3a0ed
openapi
andrewjstone 0da58dc
fix tests
andrewjstone 6f23ab7
fix doc link
andrewjstone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| //! Types used for adopting an uninitialized rack into an existing regional | ||
| //! cluster. | ||
|
|
||
| use crate::rack_setup::{ | ||
| BootstrapSledDescription, GetBgpAuthKeyInfoResponse, | ||
| UserSpecifiedRackNetworkConfig, | ||
| }; | ||
| use omicron_common::api::internal::shared::AllowedSourceIps; | ||
| use schemars::JsonSchema; | ||
| use serde::Deserialize; | ||
| use serde::Serialize; | ||
| use std::collections::BTreeSet; | ||
|
|
||
| /// Input from a user for adopting an uninitialized rack into an existing | ||
| /// regional cluster. | ||
| /// | ||
| /// This type is provided in the form of a TOML file uploaded via the wicket | ||
| /// CLI. It does not contain sensitive user input such as BGP keys. Those are | ||
| /// input separately. | ||
| #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, JsonSchema)] | ||
| pub struct MultirackJoinConfigBaseUserInput { | ||
| /// List of slot numbers only. | ||
| pub bootstrap_slots: BTreeSet<u16>, | ||
| pub rack_network_config: UserSpecifiedRackNetworkConfig, | ||
| pub allowed_source_ips: AllowedSourceIps, | ||
| } | ||
|
|
||
| /// A version of the multirack join configuration which contains learned | ||
| /// bootstrap sleds and a redacted form of BGP auth keys if they exist. | ||
| /// | ||
| /// This is returned to the user via wicketd and displayed in wicket. | ||
| /// | ||
| /// Note that there are no optional fields here unlike in | ||
| /// `CurrentRssUserConfigInsensitive`. This is because wicketd defaults | ||
| /// to filling in an empty RSS config for backwards compatibility and | ||
| /// allows uploading BGP auth keys before actually uploading the RSS | ||
| /// config. However, since we never default to an empty version of the | ||
| /// `CurrentMultirackJoinConfig`, we can only fill in the BGP auth keys for | ||
| /// this structure after the `MultirackJoinConfigBaseUserInput` is uploaded from | ||
| /// a user. | ||
| #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)] | ||
| pub struct CurrentMultirackJoinUserConfig { | ||
| pub bootstrap_sleds: BTreeSet<BootstrapSledDescription>, | ||
| pub rack_network_config: UserSpecifiedRackNetworkConfig, | ||
| pub allowed_source_ips: AllowedSourceIps, | ||
| pub bgp_auth_keys: GetBgpAuthKeyInfoResponse, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| use std::collections::BTreeMap; | ||
| use std::collections::btree_map; | ||
| use thiserror::Error; | ||
| use wicket_common::rack_setup::BgpAuthKey; | ||
| use wicket_common::rack_setup::BgpAuthKeyId; | ||
| use wicket_common::rack_setup::BgpAuthKeyStatus; | ||
| use wicket_common::rack_setup::DisplaySlice; | ||
| use wicketd_api::SetBgpAuthKeyStatus; | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Error)] | ||
| pub(crate) enum BgpAuthKeyError { | ||
| #[error( | ||
| "rack network config not set (upload the config before setting a key)" | ||
| )] | ||
| RackNetworkConfigNotSet, | ||
|
|
||
| #[error( | ||
| "key IDs not found: {} (valid key IDs: {})", | ||
| DisplaySlice(.not_found), | ||
| DisplaySlice(.valid_keys), | ||
| )] | ||
| KeyIdsNotFound { | ||
| not_found: Vec<BgpAuthKeyId>, | ||
| valid_keys: Vec<BgpAuthKeyId>, | ||
| }, | ||
| } | ||
|
|
||
| /// BGP auth keys are identified by the key ID. | ||
| /// | ||
| /// It is an invariant that any key IDs defined in `rack_network_config` exist | ||
| /// here. | ||
| /// | ||
| /// Currently these are always TCP-MD5 keys. | ||
| #[derive(Default, Clone)] | ||
| pub struct BgpAuthKeys { | ||
| keys: BTreeMap<BgpAuthKeyId, Option<BgpAuthKey>>, | ||
| } | ||
|
|
||
| impl BgpAuthKeys { | ||
| pub(crate) fn get( | ||
| &self, | ||
| key_id: &BgpAuthKeyId, | ||
| ) -> Option<&Option<BgpAuthKey>> { | ||
| self.keys.get(key_id) | ||
| } | ||
|
|
||
| pub(crate) fn iter( | ||
| &self, | ||
| ) -> btree_map::Iter<'_, BgpAuthKeyId, Option<BgpAuthKey>> { | ||
| self.keys.iter() | ||
| } | ||
|
|
||
| pub(crate) fn check_valid<'a>( | ||
| &self, | ||
| check_valid: impl IntoIterator<Item = &'a BgpAuthKeyId>, | ||
| ) -> Result<(), BgpAuthKeyError> { | ||
| let not_found: Vec<_> = check_valid | ||
| .into_iter() | ||
| .filter(|key_id| !self.keys.contains_key(key_id)) | ||
| .cloned() | ||
| .collect(); | ||
| if !not_found.is_empty() { | ||
| return Err(self.make_key_ids_not_found_error(not_found)); | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| pub(crate) fn get_data(&self) -> BTreeMap<BgpAuthKeyId, BgpAuthKeyStatus> { | ||
| self.keys | ||
| .iter() | ||
| .map(|(key_id, key)| { | ||
| let status = key | ||
| .as_ref() | ||
| .map(|key| BgpAuthKeyStatus::Set { info: key.info() }) | ||
| .unwrap_or(BgpAuthKeyStatus::Unset); | ||
| (key_id.clone(), status) | ||
| }) | ||
| .collect() | ||
| } | ||
|
|
||
| pub(crate) fn set_key( | ||
| &mut self, | ||
| key_id: BgpAuthKeyId, | ||
| key: BgpAuthKey, | ||
| ) -> Result<SetBgpAuthKeyStatus, BgpAuthKeyError> { | ||
| match self.keys.entry(key_id.clone()) { | ||
| btree_map::Entry::Occupied(mut entry) => match entry.get() { | ||
| Some(old_key) if old_key == &key => { | ||
| Ok(SetBgpAuthKeyStatus::Unchanged) | ||
| } | ||
| Some(_) => { | ||
| entry.insert(Some(key)); | ||
| Ok(SetBgpAuthKeyStatus::Replaced) | ||
| } | ||
| None => { | ||
| // This is a new key; we don't have it yet. | ||
| entry.insert(Some(key)); | ||
| Ok(SetBgpAuthKeyStatus::Added) | ||
| } | ||
| }, | ||
| btree_map::Entry::Vacant(_) => { | ||
| Err(self.make_key_ids_not_found_error(vec![key_id])) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Sync the key map with a new set of key IDs, preserving existing keys | ||
| /// where possible and dropping keys that are no longer referenced. | ||
| pub(crate) fn sync_keys( | ||
| &mut self, | ||
| new_key_ids: impl IntoIterator<Item = BgpAuthKeyId>, | ||
| ) { | ||
| let mut old_keys = std::mem::take(&mut self.keys); | ||
| self.keys = new_key_ids | ||
| .into_iter() | ||
| .map(|key_id| { | ||
| ( | ||
| key_id.clone(), | ||
| // For each new key, either grab the corresponding old key, | ||
| // or initialize to None. | ||
| old_keys.remove(&key_id).unwrap_or_else(|| None), | ||
| ) | ||
| }) | ||
| .collect(); | ||
| } | ||
|
|
||
| #[must_use] | ||
| fn make_key_ids_not_found_error( | ||
| &self, | ||
| key_ids: Vec<BgpAuthKeyId>, | ||
| ) -> BgpAuthKeyError { | ||
| let valid_key_ids = self.keys.keys().cloned().collect(); | ||
| BgpAuthKeyError::KeyIdsNotFound { | ||
| not_found: key_ids, | ||
| valid_keys: valid_key_ids, | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| pub(crate) fn insert( | ||
| &mut self, | ||
| key_id: BgpAuthKeyId, | ||
| key: Option<BgpAuthKey>, | ||
| ) { | ||
| self.keys.insert(key_id, key); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this will work for the scenario where racks are interconnected over BGP. However, for the DDM case where racks are either directly plugged into each other or are connected over a switch and are on the same broadcast domain, we need to identify what external switch ports to treat as underlay ports. One way to introduce this could be turning
UserSpecifiedPortConfiginto an enum likeWhere the
SoloRackPortConfigcontains whatUserSpecifiedPortConfigcurrently contains. I think the multi rack DDM ports should be completely self configuring and not require explicit 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.
Ah, that's great. This is the turning on all the ports to listen for router announcements/solicitations option that we discussed, right?
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.
Listening for announcements/solicitations yes, but not necessarily all ports. If we take the above approach, just the ports the user indicates as having the
MultirackDdmPortConfig.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.
Make sense. Thanks. I had inferred from the lack of a data carrying enum variant on
MultirackDdmPortConfigthat it was all ports. But that's because I was referring to theUserSpecifiedRackNetworkConfigand not per port config. Poor reading comprehension on my part.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.
@rcgoodfellow I'm looking closer at this as I'm about to start implementing, and I have a few questions.
Is the
SoloRackPortConfigreally only for the initial RSS rack? It seems like racks could have both types of port configs, and likely will.What if instead we used something like the following:
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 went ahead and added some support for this in bb42a84