Skip to content

[sled-agent-config-reconciler] Flesh out zone start/stop #8140

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

Merged
merged 5 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion illumos-utils/src/addrobj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub const DHCP_ADDROBJ_NAME: &str = "omicron";
/// ^ ^
/// | | AddrObject name
/// | Interface name
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct AddrObject {
interface: String,
name: String,
Expand Down
8 changes: 7 additions & 1 deletion illumos-utils/src/running_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,12 @@ impl RunningZone {
Ok(running_zone)
}

/// Create a fake running zone for use in tests.
#[cfg(feature = "testing")]
pub fn fake_boot(zone_id: i32, zone: InstalledZone) -> Self {
RunningZone { id: Some(zone_id), inner: zone }
}

pub async fn ensure_address(
&self,
addrtype: AddressRequest,
Expand Down Expand Up @@ -1002,7 +1008,7 @@ impl ZoneBuilderFactory {

/// For use in unit tests that don't require actual zone creation to occur.
pub fn fake(
temp_dir: Option<&String>,
temp_dir: Option<&str>,
zones_api: Arc<dyn crate::zone::Api>,
) -> Self {
let temp_dir = match temp_dir {
Expand Down
7 changes: 7 additions & 0 deletions nexus-sled-agent-shared/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ impl OmicronZoneConfig {
pub fn underlay_ip(&self) -> Ipv6Addr {
self.zone_type.underlay_ip()
}

pub fn zone_name(&self) -> String {
illumos_utils::running_zone::InstalledZone::get_zone_name(
self.zone_type.kind().zone_prefix(),
Some(self.id),
)
}
}

/// Describes a persistent ZFS dataset associated with an Omicron zone
Expand Down
1 change: 1 addition & 0 deletions sled-agent/config-reconciler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ omicron-workspace-hack.workspace = true
[dev-dependencies]
assert_matches.workspace = true
expectorate.workspace = true
illumos-utils = { workspace = true, features = ["testing"] }
omicron-test-utils.workspace = true
proptest.workspace = true
scopeguard.workspace = true
Expand Down
1 change: 1 addition & 0 deletions sled-agent/config-reconciler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub use ledger::LedgerTaskError;
pub use raw_disks::RawDisksSender;
pub use reconciler_task::CurrentlyManagedZpools;
pub use reconciler_task::CurrentlyManagedZpoolsReceiver;
pub use reconciler_task::TimeSyncError;
pub use reconciler_task::TimeSyncStatus;
pub use sled_agent_facilities::SledAgentArtifactStore;
pub use sled_agent_facilities::SledAgentFacilities;
27 changes: 3 additions & 24 deletions sled-agent/config-reconciler/src/reconciler_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
use chrono::DateTime;
use chrono::Utc;
use illumos_utils::dladm::EtherstubVnic;
use illumos_utils::running_zone::RunCommandError;
use illumos_utils::zpool::PathInPool;
use key_manager::StorageKeyRequester;
use nexus_sled_agent_shared::inventory::OmicronSledConfig;
use sled_agent_types::time_sync::TimeSync;
use slog::Logger;
use std::sync::Arc;
use std::time::Duration;
Expand All @@ -23,9 +21,12 @@ use crate::ledger::CurrentSledConfig;
use crate::sled_agent_facilities::SledAgentFacilities;

mod external_disks;
mod zones;

pub use self::external_disks::CurrentlyManagedZpools;
pub use self::external_disks::CurrentlyManagedZpoolsReceiver;
pub use self::zones::TimeSyncError;
pub use self::zones::TimeSyncStatus;

#[allow(clippy::too_many_arguments)]
pub(crate) fn spawn<T: SledAgentFacilities>(
Expand Down Expand Up @@ -113,28 +114,6 @@ pub enum ReconcilerTaskStatus {
},
}

#[derive(Debug, Clone)]
pub enum TimeSyncStatus {
NotYetChecked,
ConfiguredToSkip,
FailedToGetSyncStatus(Arc<TimeSyncError>),
TimeSync(TimeSync),
}

#[derive(Debug, thiserror::Error)]
pub enum TimeSyncError {
#[error("no running NTP zone")]
NoRunningNtpZone,
#[error("multiple running NTP zones - this should never happen!")]
MultipleRunningNtpZones,
#[error("failed to execute chronyc within NTP zone")]
ExecuteChronyc(#[source] RunCommandError),
#[error(
"failed to parse chronyc tracking output: {reason} (stdout: {stdout:?})"
)]
FailedToParse { reason: &'static str, stdout: String },
}

#[derive(Debug)]
struct LatestReconcilerTaskResultInner {
sled_config: OmicronSledConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ impl CurrentlyManagedZpools {
pub fn contains(&self, zpool: &ZpoolName) -> bool {
self.0.contains(zpool)
}

/// Within this crate, directly expose the set of zpools.
///
/// We should remove this once we clean up zone starting; starting a zone
/// should already know where to place datasets.
pub(crate) fn into_vec(self) -> Vec<ZpoolName> {
self.0.into_iter().collect()
}
}

/// Wrapper around a tokio watch channel containing the set of currently managed
Expand Down
Loading
Loading