-
Notifications
You must be signed in to change notification settings - Fork 62
[sled-agent] Integrate config-reconciler #8064
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
Changes from all commits
501f74f
ce36cb7
385807f
2abceb7
92b4916
78c60a3
6b543b8
6bce900
8ff4ae3
3ab3e79
bae91e4
2b57869
36cc3df
ecbff26
c86b51b
625ef9b
d811bda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,16 +12,14 @@ use chrono::{DateTime, Utc}; | |
| use daft::Diffable; | ||
| use id_map::IdMap; | ||
| use id_map::IdMappable; | ||
| use omicron_common::disk::{DatasetKind, DatasetName}; | ||
| use omicron_common::ledger::Ledgerable; | ||
| use omicron_common::{ | ||
| api::{ | ||
| external::{ByteCount, Generation}, | ||
| internal::shared::{NetworkInterface, SourceNatConfig}, | ||
| }, | ||
| disk::{ | ||
| DatasetConfig, DatasetManagementStatus, DiskManagementStatus, | ||
| DiskVariant, OmicronPhysicalDiskConfig, | ||
| }, | ||
| disk::{DatasetConfig, DiskVariant, OmicronPhysicalDiskConfig}, | ||
| update::ArtifactId, | ||
| zpool_name::ZpoolName, | ||
| }; | ||
|
|
@@ -132,6 +130,49 @@ pub struct ConfigReconcilerInventory { | |
| pub zones: BTreeMap<OmicronZoneUuid, ConfigReconcilerInventoryResult>, | ||
| } | ||
|
|
||
| impl ConfigReconcilerInventory { | ||
| /// Iterate over all running zones as reported by the last reconciliation | ||
| /// result. | ||
| /// | ||
| /// This includes zones that are both present in `last_reconciled_config` | ||
| /// and whose status in `zones` indicates "successfully running". | ||
| pub fn running_omicron_zones( | ||
| &self, | ||
| ) -> impl Iterator<Item = &OmicronZoneConfig> { | ||
| self.zones.iter().filter_map(|(zone_id, result)| match result { | ||
| ConfigReconcilerInventoryResult::Ok => { | ||
| self.last_reconciled_config.zones.get(zone_id) | ||
| } | ||
| ConfigReconcilerInventoryResult::Err { .. } => None, | ||
| }) | ||
| } | ||
|
|
||
| /// Given a sled config, produce a reconciler result that sled-agent could | ||
| /// have emitted if reconciliation succeeded. | ||
| /// | ||
| /// This method should only be used by tests and dev tools; real code should | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we mark this with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we can, because of the "and dev tools". IIRC reconfigurator-cli and some of the "example system" stuff uses this, neither of which is gated by |
||
| /// look at the actual `last_reconciliation` value from the parent | ||
| /// [`Inventory`]. | ||
| pub fn debug_assume_success(config: OmicronSledConfig) -> Self { | ||
| let external_disks = config | ||
| .disks | ||
| .iter() | ||
| .map(|d| (d.id, ConfigReconcilerInventoryResult::Ok)) | ||
| .collect(); | ||
| let datasets = config | ||
| .datasets | ||
| .iter() | ||
| .map(|d| (d.id, ConfigReconcilerInventoryResult::Ok)) | ||
| .collect(); | ||
| let zones = config | ||
| .zones | ||
| .iter() | ||
| .map(|z| (z.id, ConfigReconcilerInventoryResult::Ok)) | ||
| .collect(); | ||
| Self { last_reconciled_config: config, external_disks, datasets, zones } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, PartialEq, Eq, Deserialize, JsonSchema, Serialize)] | ||
| #[serde(tag = "result", rename_all = "snake_case")] | ||
| pub enum ConfigReconcilerInventoryResult { | ||
|
|
@@ -187,8 +228,6 @@ pub enum SledRole { | |
| } | ||
|
|
||
| /// Describes the set of Reconfigurator-managed configuration elements of a sled | ||
| // TODO this struct should have a generation number; at the moment, each of | ||
| // the fields has a separete one internally. | ||
| #[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq)] | ||
| pub struct OmicronSledConfig { | ||
| pub generation: Generation, | ||
|
|
@@ -223,14 +262,6 @@ impl Ledgerable for OmicronSledConfig { | |
| } | ||
| } | ||
|
|
||
| /// Result of the currently-synchronous `omicron_config_put` endpoint. | ||
| #[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)] | ||
| #[must_use = "this `DatasetManagementResult` may contain errors, which should be handled"] | ||
| pub struct OmicronSledConfigResult { | ||
| pub disks: Vec<DiskManagementStatus>, | ||
| pub datasets: Vec<DatasetManagementStatus>, | ||
| } | ||
|
|
||
| /// Describes the set of Omicron-managed zones running on a sled | ||
| #[derive( | ||
| Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash, | ||
|
|
@@ -297,6 +328,10 @@ impl OmicronZoneConfig { | |
| Some(self.id), | ||
| ) | ||
| } | ||
|
|
||
| pub fn dataset_name(&self) -> Option<DatasetName> { | ||
| self.zone_type.dataset_name() | ||
| } | ||
| } | ||
|
|
||
| /// Describes a persistent ZFS dataset associated with an Omicron zone | ||
|
|
@@ -583,6 +618,41 @@ impl OmicronZoneType { | |
| | OmicronZoneType::Oximeter { .. } => None, | ||
| } | ||
| } | ||
|
|
||
| /// If this kind of zone has an associated dataset, return the dataset's | ||
| /// name. Otherwise, return `None`. | ||
| pub fn dataset_name(&self) -> Option<DatasetName> { | ||
| let (dataset, dataset_kind) = match self { | ||
| OmicronZoneType::BoundaryNtp { .. } | ||
| | OmicronZoneType::InternalNtp { .. } | ||
| | OmicronZoneType::Nexus { .. } | ||
| | OmicronZoneType::Oximeter { .. } | ||
| | OmicronZoneType::CruciblePantry { .. } => None, | ||
| OmicronZoneType::Clickhouse { dataset, .. } => { | ||
| Some((dataset, DatasetKind::Clickhouse)) | ||
| } | ||
| OmicronZoneType::ClickhouseKeeper { dataset, .. } => { | ||
| Some((dataset, DatasetKind::ClickhouseKeeper)) | ||
| } | ||
| OmicronZoneType::ClickhouseServer { dataset, .. } => { | ||
| Some((dataset, DatasetKind::ClickhouseServer)) | ||
| } | ||
| OmicronZoneType::CockroachDb { dataset, .. } => { | ||
| Some((dataset, DatasetKind::Cockroach)) | ||
| } | ||
| OmicronZoneType::Crucible { dataset, .. } => { | ||
| Some((dataset, DatasetKind::Crucible)) | ||
| } | ||
| OmicronZoneType::ExternalDns { dataset, .. } => { | ||
| Some((dataset, DatasetKind::ExternalDns)) | ||
| } | ||
| OmicronZoneType::InternalDns { dataset, .. } => { | ||
| Some((dataset, DatasetKind::InternalDns)) | ||
| } | ||
| }?; | ||
|
|
||
| Some(DatasetName::new(dataset.pool_name, dataset_kind)) | ||
| } | ||
| } | ||
|
|
||
| /// Like [`OmicronZoneType`], but without any associated data. | ||
|
|
||
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.
Are you expecting that inventory will supplant this info? Or are you planning on replacing this access to the sled agent 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 was expecting that inventory would supplant this. (I think maybe it already has, in practice? I definitely only look at inventory when I'm curious about zpools; I don't think I've ever used these omdb subcommands.)