Skip to content

Commit 88dd21c

Browse files
committed
[sled-agent-config-reconciler] Flesh out zone start/stop
1 parent 00d0a38 commit 88dd21c

File tree

11 files changed

+1146
-47
lines changed

11 files changed

+1146
-47
lines changed

illumos-utils/src/addrobj.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub const DHCP_ADDROBJ_NAME: &str = "omicron";
2626
/// ^ ^
2727
/// | | AddrObject name
2828
/// | Interface name
29-
#[derive(Debug, PartialEq, Clone)]
29+
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
3030
pub struct AddrObject {
3131
interface: String,
3232
name: String,

illumos-utils/src/running_zone.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,12 @@ impl RunningZone {
508508
Ok(running_zone)
509509
}
510510

511+
/// Create a fake running zone for use in tests.
512+
#[cfg(feature = "testing")]
513+
pub fn fake_boot(zone_id: i32, zone: InstalledZone) -> Self {
514+
RunningZone { id: Some(zone_id), inner: zone }
515+
}
516+
511517
pub async fn ensure_address(
512518
&self,
513519
addrtype: AddressRequest,

nexus-sled-agent-shared/src/inventory.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ impl OmicronZoneConfig {
221221
pub fn underlay_ip(&self) -> Ipv6Addr {
222222
self.zone_type.underlay_ip()
223223
}
224+
225+
pub fn zone_name(&self) -> String {
226+
illumos_utils::running_zone::InstalledZone::get_zone_name(
227+
self.zone_type.kind().zone_prefix(),
228+
Some(self.id),
229+
)
230+
}
224231
}
225232

226233
/// Describes a persistent ZFS dataset associated with an Omicron zone

sled-agent/config-reconciler/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ omicron-workspace-hack.workspace = true
4141
[dev-dependencies]
4242
assert_matches.workspace = true
4343
expectorate.workspace = true
44+
illumos-utils = { workspace = true, features = ["testing"] }
4445
omicron-test-utils.workspace = true
4546
proptest.workspace = true
4647
scopeguard.workspace = true

sled-agent/config-reconciler/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub use ledger::LedgerTaskError;
8080
pub use raw_disks::RawDisksSender;
8181
pub use reconciler_task::CurrentlyManagedZpools;
8282
pub use reconciler_task::CurrentlyManagedZpoolsReceiver;
83+
pub use reconciler_task::TimeSyncError;
8384
pub use reconciler_task::TimeSyncStatus;
8485
pub use sled_agent_facilities::SledAgentArtifactStore;
8586
pub use sled_agent_facilities::SledAgentFacilities;

sled-agent/config-reconciler/src/reconciler_task.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
use chrono::DateTime;
88
use chrono::Utc;
99
use illumos_utils::dladm::EtherstubVnic;
10-
use illumos_utils::running_zone::RunCommandError;
1110
use illumos_utils::zpool::PathInPool;
1211
use key_manager::StorageKeyRequester;
1312
use nexus_sled_agent_shared::inventory::OmicronSledConfig;
14-
use sled_agent_types::time_sync::TimeSync;
1513
use slog::Logger;
1614
use std::sync::Arc;
1715
use std::time::Duration;
@@ -23,9 +21,12 @@ use crate::ledger::CurrentSledConfig;
2321
use crate::sled_agent_facilities::SledAgentFacilities;
2422

2523
mod external_disks;
24+
mod zones;
2625

2726
pub use self::external_disks::CurrentlyManagedZpools;
2827
pub use self::external_disks::CurrentlyManagedZpoolsReceiver;
28+
pub use self::zones::TimeSyncError;
29+
pub use self::zones::TimeSyncStatus;
2930

3031
#[allow(clippy::too_many_arguments)]
3132
pub(crate) fn spawn<T: SledAgentFacilities>(
@@ -113,28 +114,6 @@ pub enum ReconcilerTaskStatus {
113114
},
114115
}
115116

116-
#[derive(Debug, Clone)]
117-
pub enum TimeSyncStatus {
118-
NotYetChecked,
119-
ConfiguredToSkip,
120-
FailedToGetSyncStatus(Arc<TimeSyncError>),
121-
TimeSync(TimeSync),
122-
}
123-
124-
#[derive(Debug, thiserror::Error)]
125-
pub enum TimeSyncError {
126-
#[error("no running NTP zone")]
127-
NoRunningNtpZone,
128-
#[error("multiple running NTP zones - this should never happen!")]
129-
MultipleRunningNtpZones,
130-
#[error("failed to execute chronyc within NTP zone")]
131-
ExecuteChronyc(#[source] RunCommandError),
132-
#[error(
133-
"failed to parse chronyc tracking output: {reason} (stdout: {stdout:?})"
134-
)]
135-
FailedToParse { reason: &'static str, stdout: String },
136-
}
137-
138117
#[derive(Debug)]
139118
struct LatestReconcilerTaskResultInner {
140119
sled_config: OmicronSledConfig,

sled-agent/config-reconciler/src/reconciler_task/external_disks.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ impl CurrentlyManagedZpools {
5555
pub fn contains(&self, zpool: &ZpoolName) -> bool {
5656
self.0.contains(zpool)
5757
}
58+
59+
/// Within this crate, directly expose the set of zpools.
60+
///
61+
/// We should remove this once we clean up zone starting; starting a zone
62+
/// should already know where to place datasets.
63+
pub(crate) fn into_vec(self) -> Vec<ZpoolName> {
64+
self.0.into_iter().collect()
65+
}
5866
}
5967

6068
/// Wrapper around a tokio watch channel containing the set of currently managed

0 commit comments

Comments
 (0)