-
Notifications
You must be signed in to change notification settings - Fork 44
[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
base: main
Are you sure you want to change the base?
Changes from all commits
501f74f
ce36cb7
385807f
2abceb7
92b4916
78c60a3
6b543b8
6bce900
8ff4ae3
3ab3e79
bae91e4
2b57869
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 |
---|---|---|
|
@@ -18,10 +18,7 @@ use omicron_common::{ | |
external::{ByteCount, Generation}, | ||
internal::shared::{NetworkInterface, SourceNatConfig}, | ||
}, | ||
disk::{ | ||
DatasetConfig, DatasetManagementStatus, DiskManagementStatus, | ||
DiskVariant, OmicronPhysicalDiskConfig, | ||
}, | ||
disk::{DatasetConfig, DiskVariant, OmicronPhysicalDiskConfig}, | ||
zpool_name::ZpoolName, | ||
}; | ||
use omicron_uuid_kinds::{DatasetUuid, OmicronZoneUuid}; | ||
|
@@ -131,6 +128,50 @@ 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 => (), | ||
ConfigReconcilerInventoryResult::Err { .. } => return None, | ||
}; | ||
self.last_reconciled_config.zones.get(zone_id) | ||
}) | ||
} | ||
|
||
/// 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 | ||
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 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 { | ||
|
@@ -186,8 +227,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, | ||
|
@@ -222,14 +261,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, | ||
|
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.)