Skip to content

[4/n] [sled-agent] add code to read mupdate overrides #8081

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
wants to merge 11 commits into
base: sunshowers/spr/main.sled-agent-add-code-to-read-mupdate-overrides
Choose a base branch
from
Open
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
79 changes: 64 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ byteorder = "1.5.0"
bytes = "1.10.1"
camino = { version = "1.1", features = ["serde1"] }
camino-tempfile = "1.3.0"
camino-tempfile-ext = { version = "0.3.0", features = ["assert-color"] }
cancel-safe-futures = "0.1.5"
cargo_metadata = "0.19.2"
chacha20poly1305 = "0.10.1"
Expand Down
1 change: 1 addition & 0 deletions sled-agent/src/bootstrap/pre_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ impl BootstrapAgentStartup {
config.switch_zone_maghemite_links.clone(),
long_running_task_handles.storage_manager.clone(),
long_running_task_handles.zone_bundler.clone(),
long_running_task_handles.zone_image_resolver.clone(),
);

// Inform the hardware monitor that the service manager is ready
Expand Down
35 changes: 30 additions & 5 deletions sled-agent/src/long_running_tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ use crate::sled_agent::SledAgent;
use crate::storage_monitor::{StorageMonitor, StorageMonitorHandle};
use crate::zone_bundle::ZoneBundler;
use bootstore::schemes::v0 as bootstore;
use illumos_utils::zpool::ZpoolName;
use key_manager::{KeyManager, StorageKeyRequester};
use sled_agent_types::zone_bundle::CleanupContext;
use sled_agent_zone_images::{ZoneImageSourceResolver, ZoneImageZpools};
use sled_hardware::{HardwareManager, SledMode, UnparsedDisk};
use sled_storage::config::MountConfig;
use sled_storage::disk::RawSyntheticDisk;
use sled_storage::manager::{StorageHandle, StorageManager};
use sled_storage::resources::AllDisks;
use slog::{Logger, info};
use std::net::Ipv6Addr;
use tokio::sync::oneshot;
Expand Down Expand Up @@ -59,6 +62,13 @@ pub struct LongRunningTaskHandles {

// A reference to the object used to manage zone bundles
pub zone_bundler: ZoneBundler,

/// Resolver for zone image sources.
///
/// This isn't really implemented in the backend as a task per se, but it
/// looks like one from the outside, and is convenient to put here. (If it
/// had any async involved within it, it would be a task.)
pub zone_image_resolver: ZoneImageSourceResolver,
}

/// Spawn all long running tasks
Expand Down Expand Up @@ -95,18 +105,21 @@ pub async fn spawn_all_longrunning_tasks(
// Wait for the boot disk so that we can work with any ledgers,
// such as those needed by the bootstore and sled-agent
info!(log, "Waiting for boot disk");
let (disk_id, _) = storage_manager.wait_for_boot_disk().await;
let (disk_id, boot_zpool) = storage_manager.wait_for_boot_disk().await;
info!(log, "Found boot disk {:?}", disk_id);

let all_disks = storage_manager.get_latest_disks().await;
let bootstore = spawn_bootstore_tasks(
log,
&mut storage_manager,
&all_disks,
&hardware_manager,
global_zone_bootstrap_ip,
)
.await;

let zone_bundler = spawn_zone_bundler_tasks(log, &mut storage_manager);
let zone_image_resolver =
make_zone_image_resolver(log, &all_disks, &boot_zpool);

(
LongRunningTaskHandles {
Expand All @@ -116,6 +129,7 @@ pub async fn spawn_all_longrunning_tasks(
hardware_manager,
bootstore,
zone_bundler,
zone_image_resolver,
},
sled_agent_started_tx,
service_manager_ready_tx,
Expand Down Expand Up @@ -195,13 +209,12 @@ fn spawn_hardware_monitor(

async fn spawn_bootstore_tasks(
log: &Logger,
storage_handle: &mut StorageHandle,
all_disks: &AllDisks,
hardware_manager: &HardwareManager,
global_zone_bootstrap_ip: Ipv6Addr,
) -> bootstore::NodeHandle {
let iter_all = storage_handle.get_latest_disks().await;
let config = new_bootstore_config(
&iter_all,
all_disks,
hardware_manager.baseboard(),
global_zone_bootstrap_ip,
)
Expand Down Expand Up @@ -233,6 +246,18 @@ fn spawn_zone_bundler_tasks(
ZoneBundler::new(log, storage_handle.clone(), CleanupContext::default())
}

fn make_zone_image_resolver(
log: &Logger,
all_disks: &AllDisks,
boot_zpool: &ZpoolName,
) -> ZoneImageSourceResolver {
let zpools = ZoneImageZpools {
root: &all_disks.mount_config().root,
all_m2_zpools: all_disks.all_m2_zpools(),
};
ZoneImageSourceResolver::new(log, &zpools, boot_zpool)
}

async fn upsert_synthetic_disks_if_needed(
log: &Logger,
storage_manager: &StorageHandle,
Expand Down
19 changes: 18 additions & 1 deletion sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ impl ServiceManager {
switch_zone_maghemite_links: Vec<PhysicalLink>,
storage: StorageHandle,
zone_bundler: ZoneBundler,
zone_image_resolver: ZoneImageSourceResolver,
) -> Self {
Self::new_inner(
log,
Expand All @@ -940,6 +941,7 @@ impl ServiceManager {
switch_zone_maghemite_links,
storage,
zone_bundler,
zone_image_resolver,
RealSystemApi::new(),
)
}
Expand All @@ -955,6 +957,7 @@ impl ServiceManager {
switch_zone_maghemite_links: Vec<PhysicalLink>,
storage: StorageHandle,
zone_bundler: ZoneBundler,
zone_image_resolver: ZoneImageSourceResolver,
system_api: Box<dyn SystemApi>,
) -> Self {
let log = log.new(o!("component" => "ServiceManager"));
Expand Down Expand Up @@ -990,7 +993,7 @@ impl ServiceManager {
.switch_zone_bootstrap_ip,
storage,
zone_bundler,
zone_image_resolver: ZoneImageSourceResolver::new(),
zone_image_resolver,
ledger_directory_override: OnceLock::new(),
system_api,
}),
Expand Down Expand Up @@ -5141,6 +5144,7 @@ mod illumos_tests {

use nexus_sled_agent_shared::inventory::OmicronZoneImageSource;
use omicron_uuid_kinds::OmicronZoneUuid;
use sled_agent_zone_images::ZoneImageZpools;
use sled_storage::manager_test_harness::StorageManagerTestHarness;
use std::{
net::{Ipv6Addr, SocketAddrV6},
Expand Down Expand Up @@ -5342,6 +5346,7 @@ mod illumos_tests {
log: slog::Logger,
storage_test_harness: StorageManagerTestHarness,
zone_bundler: ZoneBundler,
zone_image_resolver: ZoneImageSourceResolver,
test_config: &'a TestConfig,
}

Expand All @@ -5354,10 +5359,21 @@ mod illumos_tests {
Default::default(),
);

let mut storage_manager = storage_test_harness.handle().clone();
let all_disks = storage_manager.get_latest_disks().await;
let (_, boot_zpool) = storage_manager.wait_for_boot_disk().await;
let zpools = ZoneImageZpools {
root: &all_disks.mount_config().root,
all_m2_zpools: all_disks.all_m2_zpools(),
};
let zone_image_resolver =
ZoneImageSourceResolver::new(&log, &zpools, &boot_zpool);

LedgerTestHelper {
log,
storage_test_harness,
zone_bundler,
zone_image_resolver,
test_config,
}
}
Expand Down Expand Up @@ -5392,6 +5408,7 @@ mod illumos_tests {
vec![],
self.storage_test_harness.handle().clone(),
self.zone_bundler.clone(),
self.zone_image_resolver.clone(),
system,
);
self.test_config.override_paths(&mgr);
Expand Down
13 changes: 13 additions & 0 deletions sled-agent/zone-images/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ workspace = true
[dependencies]
anyhow.workspace = true
camino.workspace = true
id-map.workspace = true
illumos-utils.workspace = true
nexus-sled-agent-shared.workspace = true
omicron-common.workspace = true
omicron-workspace-hack.workspace = true
serde_json.workspace = true
sled-storage.workspace = true
slog.workspace = true
slog-error-chain.workspace = true
thiserror.workspace = true

[dev-dependencies]
camino-tempfile-ext.workspace = true
dropshot.workspace = true
omicron-uuid-kinds.workspace = true
pretty_assertions.workspace = true
2 changes: 2 additions & 0 deletions sled-agent/zone-images/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//! This contains a subset of zone image code at the moment: you're encouraged
//! to move more code into this crate as appropriate.

mod mupdate_override;
mod source_resolver;

pub(crate) use mupdate_override::*;
pub use source_resolver::*;
Loading
Loading