diff --git a/sled-agent/config-reconciler/src/dump_setup.rs b/sled-agent/config-reconciler/src/debug_collector.rs similarity index 97% rename from sled-agent/config-reconciler/src/dump_setup.rs rename to sled-agent/config-reconciler/src/debug_collector.rs index 91726253cca..8d41ff5de3d 100644 --- a/sled-agent/config-reconciler/src/dump_setup.rs +++ b/sled-agent/config-reconciler/src/debug_collector.rs @@ -186,7 +186,7 @@ trait GetMountpoint: AsRef { } #[derive(Debug)] -enum DumpSetupCmd { +enum DebugCollectorCmd { ArchiveFormerZoneRoot { zone_root: Utf8PathBuf, zone_name: String, @@ -200,7 +200,7 @@ enum DumpSetupCmd { }, } -struct DumpSetupWorker { +struct DebugCollectorWorker { core_dataset_names: Vec, debug_dataset_names: Vec, @@ -215,32 +215,32 @@ struct DumpSetupWorker { savecored_slices: HashSet, log: Logger, - rx: Receiver, + rx: Receiver, coredumpadm_invoker: Box, zfs_invoker: Box, zone_invoker: Box, } -pub struct DumpSetup { - tx: tokio::sync::mpsc::Sender, +pub struct DebugCollector { + tx: tokio::sync::mpsc::Sender, mount_config: Arc, _poller: tokio::task::JoinHandle<()>, log: Logger, } -impl DumpSetup { +impl DebugCollector { pub fn new(log: &Logger, mount_config: Arc) -> Self { let (tx, rx) = tokio::sync::mpsc::channel(16); - let worker = DumpSetupWorker::new( + let worker = DebugCollectorWorker::new( Box::new(RealCoreDumpAdm {}), Box::new(RealZfs {}), Box::new(RealZone {}), - log.new(o!("component" => "DumpSetup-worker")), + log.new(o!("component" => "DebugCollector-worker")), rx, ); let _poller = tokio::spawn(async move { worker.poll_file_archival().await }); - let log = log.new(o!("component" => "DumpSetup")); + let log = log.new(o!("component" => "DebugCollector")); Self { tx, mount_config, _poller, log } } @@ -249,7 +249,7 @@ impl DumpSetup { /// /// This function returns only once this request has been handled, which /// can be used as a signal by callers that any "old disks" are no longer - /// being used by [DumpSetup]. + /// being used by [DebugCollector]. pub async fn update_dumpdev_setup( &self, disks: impl Iterator, @@ -322,7 +322,7 @@ impl DumpSetup { let (tx, rx) = oneshot::channel(); if let Err(err) = self .tx - .send(DumpSetupCmd::UpdateDumpdevSetup { + .send(DebugCollectorCmd::UpdateDumpdevSetup { dump_slices: m2_dump_slices, debug_datasets: u2_debug_datasets, core_datasets: m2_core_datasets, @@ -330,11 +330,11 @@ impl DumpSetup { }) .await { - error!(log, "DumpSetup channel closed: {:?}", err.0); + error!(log, "DebugCollector channel closed: {:?}", err.0); }; if let Err(err) = rx.await { - error!(log, "DumpSetup failed to await update"; "err" => ?err); + error!(log, "DebugCollector failed to await update"; "err" => ?err); } } @@ -383,7 +383,7 @@ impl DumpSetup { info!(log, "requesting archive of former zone root"); let zone_root = zone_root.to_owned(); let zone_name = file_name.to_string(); - let cmd = DumpSetupCmd::ArchiveFormerZoneRoot { + let cmd = DebugCollectorCmd::ArchiveFormerZoneRoot { zone_root, zone_name, completion_tx, @@ -392,7 +392,7 @@ impl DumpSetup { error!( log, "failed to request archive of former zone root"; - "error" => "DumpSetup channel closed" + "error" => "DebugCollector channel closed" ); } } @@ -603,13 +603,13 @@ fn safe_to_delete(path: &Utf8Path, meta: &std::fs::Metadata) -> bool { return true; } -impl DumpSetupWorker { +impl DebugCollectorWorker { fn new( coredumpadm_invoker: Box, zfs_invoker: Box, zone_invoker: Box, log: Logger, - rx: Receiver, + rx: Receiver, ) -> Self { Self { core_dataset_names: vec![], @@ -630,7 +630,7 @@ impl DumpSetupWorker { } async fn poll_file_archival(mut self) { - info!(self.log, "DumpSetup poll loop started."); + info!(self.log, "DebugCollector poll loop started."); // A oneshot which helps callers track when updates have propagated. // @@ -642,7 +642,7 @@ impl DumpSetupWorker { loop { match tokio::time::timeout(ARCHIVAL_INTERVAL, self.rx.recv()).await { - Ok(Some(DumpSetupCmd::UpdateDumpdevSetup { + Ok(Some(DebugCollectorCmd::UpdateDumpdevSetup { dump_slices, debug_datasets, core_datasets, @@ -656,7 +656,7 @@ impl DumpSetupWorker { core_datasets, ); } - Ok(Some(DumpSetupCmd::ArchiveFormerZoneRoot { + Ok(Some(DebugCollectorCmd::ArchiveFormerZoneRoot { zone_root, zone_name, completion_tx, @@ -1586,7 +1586,7 @@ mod tests { ); const NOT_MOUNTED_INTERNAL: &str = "oxi_acab2069-6e63-6c75-de73-20c06c756db0"; - let mut worker = DumpSetupWorker::new( + let mut worker = DebugCollectorWorker::new( Box::::default(), Box::new(FakeZfs { zpool_props: [( @@ -1641,7 +1641,7 @@ mod tests { name: ZpoolName::from_str(ERROR_INTERNAL).unwrap(), }; const ZPOOL_MNT: &str = "/path/to/internal/zpool"; - let mut worker = DumpSetupWorker::new( + let mut worker = DebugCollectorWorker::new( Box::::default(), Box::new(FakeZfs { zpool_props: [ @@ -1732,7 +1732,7 @@ mod tests { let logctx = omicron_test_utils::dev::test_setup_log( "test_savecore_and_dumpadm_not_called_when_occupied_and_no_dir", ); - let mut worker = DumpSetupWorker::new( + let mut worker = DebugCollectorWorker::new( Box::::default(), Box::::default(), Box::::default(), @@ -1760,7 +1760,7 @@ mod tests { let logctx = omicron_test_utils::dev::test_setup_log( "test_dumpadm_called_when_vacant_slice_but_no_dir", ); - let mut worker = DumpSetupWorker::new( + let mut worker = DebugCollectorWorker::new( Box::::default(), Box::::default(), Box::::default(), @@ -1791,7 +1791,7 @@ mod tests { const MOUNTED_EXTERNAL: &str = "oxp_446f6e74-4469-6557-6f6e-646572696e67"; const ZPOOL_MNT: &str = "/path/to/external/zpool"; - let mut worker = DumpSetupWorker::new( + let mut worker = DebugCollectorWorker::new( Box::::default(), Box::new(FakeZfs { zpool_props: [( @@ -1853,7 +1853,7 @@ mod tests { "oxi_474e554e-6174-616c-6965-4e677579656e"; const MOUNTED_EXTERNAL: &str = "oxp_446f6e74-4469-6557-6f6e-646572696e67"; - let mut worker = DumpSetupWorker::new( + let mut worker = DebugCollectorWorker::new( Box::::default(), Box::new(FakeZfs { zpool_props: [ @@ -1981,15 +1981,15 @@ mod tests { } } - async fn new_dump_setup_worker( + async fn new_debug_collector_worker( &self, used: u64, available: u64, - ) -> DumpSetupWorker { + ) -> DebugCollectorWorker { let tempdir_path = self.tempdir.path().to_string(); const MOUNTED_EXTERNAL: &str = "oxp_446f6e74-4469-6557-6f6e-646572696e67"; - let mut worker = DumpSetupWorker::new( + let mut worker = DebugCollectorWorker::new( Box::::default(), Box::new(FakeZfs { zpool_props: [ @@ -2190,7 +2190,7 @@ mod tests { USED, CAPACITY, ); - let worker = files.new_dump_setup_worker(USED, AVAILABLE).await; + let worker = files.new_debug_collector_worker(USED, AVAILABLE).await; // Before we cleanup: All files in "debug" exist files.check_all_files_exist(); @@ -2232,7 +2232,7 @@ mod tests { USED, CAPACITY, ); - let worker = files.new_dump_setup_worker(USED, AVAILABLE).await; + let worker = files.new_debug_collector_worker(USED, AVAILABLE).await; // Before we cleanup: All files in "debug" exist files.check_all_files_exist(); @@ -2290,7 +2290,7 @@ mod tests { USED, CAPACITY, ); - let worker = files.new_dump_setup_worker(USED, AVAILABLE).await; + let worker = files.new_debug_collector_worker(USED, AVAILABLE).await; // Before we cleanup: All files in "debug" exist files.check_all_files_exist(); @@ -2351,7 +2351,7 @@ mod tests { USED, CAPACITY, ); - let worker = files.new_dump_setup_worker(USED, AVAILABLE).await; + let worker = files.new_debug_collector_worker(USED, AVAILABLE).await; // Before we cleanup: All files in "debug" exist files.check_all_files_exist(); diff --git a/sled-agent/config-reconciler/src/dump_setup_task.rs b/sled-agent/config-reconciler/src/debug_collector_task.rs similarity index 92% rename from sled-agent/config-reconciler/src/dump_setup_task.rs rename to sled-agent/config-reconciler/src/debug_collector_task.rs index 5b03194b565..a82fb28c5e4 100644 --- a/sled-agent/config-reconciler/src/dump_setup_task.rs +++ b/sled-agent/config-reconciler/src/debug_collector_task.rs @@ -6,7 +6,7 @@ //! response to changes in available disks. use crate::InternalDisksReceiver; -use crate::dump_setup::DumpSetup; +use crate::debug_collector::DebugCollector; use camino::Utf8PathBuf; use debug_ignore::DebugIgnore; use sled_storage::config::MountConfig; @@ -33,16 +33,16 @@ pub(crate) fn spawn( // to enqueue the request or for the request to complete. let (archive_tx, archive_rx) = mpsc::channel(1); - let dump_setup_task = DumpSetupTask { + let debug_collector_task = DebugCollectorTask { internal_disks_rx, external_disks_rx, archive_rx, - dump_setup: DumpSetup::new(base_log, mount_config), + debug_collector: DebugCollector::new(base_log, mount_config), last_disks_used: HashSet::new(), - log: base_log.new(slog::o!("component" => "DumpSetupTask")), + log: base_log.new(slog::o!("component" => "DebugCollectorTask")), }; - tokio::spawn(dump_setup_task.run()); + tokio::spawn(debug_collector_task.run()); FormerZoneRootArchiver { log: DebugIgnore( @@ -52,7 +52,7 @@ pub(crate) fn spawn( } } -struct DumpSetupTask { +struct DebugCollectorTask { // Input channels on which we receive updates about disk changes. internal_disks_rx: InternalDisksReceiver, external_disks_rx: watch::Receiver>, @@ -60,15 +60,16 @@ struct DumpSetupTask { archive_rx: mpsc::Receiver, // Invokes dumpadm(8) and savecore(8) when new disks are encountered - dump_setup: DumpSetup, + debug_collector: DebugCollector, - // Set of internal + external disks we most recently passed to `dump_setup`. + // Set of internal + external disks we most recently passed to the + // Debug Collector last_disks_used: HashSet, log: Logger, } -impl DumpSetupTask { +impl DebugCollectorTask { async fn run(mut self) { self.update_setup_if_needed().await; @@ -119,7 +120,7 @@ impl DumpSetupTask { completion_tx } = request; self - .dump_setup + .debug_collector .archive_former_zone_root(&path, completion_tx) .await; } @@ -138,7 +139,7 @@ impl DumpSetupTask { .collect::>(); if disks_avail != self.last_disks_used { - self.dump_setup.update_dumpdev_setup(disks_avail.iter()).await; + self.debug_collector.update_dumpdev_setup(disks_avail.iter()).await; self.last_disks_used = disks_avail; } } diff --git a/sled-agent/config-reconciler/src/handle.rs b/sled-agent/config-reconciler/src/handle.rs index 4851c06c1f8..428abb5d5a0 100644 --- a/sled-agent/config-reconciler/src/handle.rs +++ b/sled-agent/config-reconciler/src/handle.rs @@ -50,8 +50,8 @@ use crate::SledAgentFacilities; use crate::TimeSyncStatus; use crate::dataset_serialization_task::DatasetTaskHandle; use crate::dataset_serialization_task::NestedDatasetMountError; -use crate::dump_setup_task; -use crate::dump_setup_task::FormerZoneRootArchiver; +use crate::debug_collector_task; +use crate::debug_collector_task::FormerZoneRootArchiver; use crate::internal_disks::InternalDisksReceiver; use crate::ledger::CurrentSledConfig; use crate::ledger::LedgerTaskHandle; @@ -136,7 +136,7 @@ impl ConfigReconcilerHandle { // Spawn the task that manages dump devices. let (external_disks_tx, external_disks_rx) = watch::channel(HashSet::new()); - let former_zone_root_archiver = dump_setup_task::spawn( + let former_zone_root_archiver = debug_collector_task::spawn( internal_disks_rx.clone(), external_disks_rx, Arc::clone(&mount_config), diff --git a/sled-agent/config-reconciler/src/lib.rs b/sled-agent/config-reconciler/src/lib.rs index 22e0d4dc82f..a56d36dcda3 100644 --- a/sled-agent/config-reconciler/src/lib.rs +++ b/sled-agent/config-reconciler/src/lib.rs @@ -46,9 +46,9 @@ //! [`ConfigReconcilerHandle::inventory()`]. mod dataset_serialization_task; +mod debug_collector; +mod debug_collector_task; mod disks_common; -mod dump_setup; -mod dump_setup_task; mod handle; mod host_phase_2; mod internal_disks; diff --git a/sled-agent/config-reconciler/src/reconciler_task.rs b/sled-agent/config-reconciler/src/reconciler_task.rs index 1277bd73f66..f63a09a4885 100644 --- a/sled-agent/config-reconciler/src/reconciler_task.rs +++ b/sled-agent/config-reconciler/src/reconciler_task.rs @@ -42,7 +42,7 @@ use crate::InternalDisksReceiver; use crate::SledAgentArtifactStore; use crate::TimeSyncConfig; use crate::dataset_serialization_task::DatasetTaskHandle; -use crate::dump_setup_task::FormerZoneRootArchiver; +use crate::debug_collector_task::FormerZoneRootArchiver; use crate::host_phase_2::BootPartitionReconciler; use crate::ledger::CurrentSledConfig; use crate::raw_disks::RawDisksReceiver; diff --git a/sled-agent/config-reconciler/src/reconciler_task/external_disks.rs b/sled-agent/config-reconciler/src/reconciler_task/external_disks.rs index c794c1dc388..5574af8ee7e 100644 --- a/sled-agent/config-reconciler/src/reconciler_task/external_disks.rs +++ b/sled-agent/config-reconciler/src/reconciler_task/external_disks.rs @@ -45,9 +45,9 @@ use std::sync::Arc; use std::sync::OnceLock; use tokio::sync::watch; +use crate::debug_collector_task::FormerZoneRootArchiver; use crate::disks_common::MaybeUpdatedDisk; use crate::disks_common::update_properties_from_raw_disk; -use crate::dump_setup_task::FormerZoneRootArchiver; use camino::Utf8PathBuf; use illumos_utils::zfs::Mountpoint; @@ -238,7 +238,7 @@ pub(super) struct ExternalDisks { currently_managed_zpools_tx: watch::Sender>, // Output channel for the raw disks we're managing. This is only consumed - // within this crate by `DumpSetupTask` (for managing dump devices). + // within this crate by `DebugCollectorTask` (for managing dump devices). external_disks_tx: watch::Sender>, // For requesting archival of former zone root directories. @@ -501,8 +501,8 @@ impl ExternalDisks { // Update the output channels now. This is important to do before // cleaning up former zone root datasets because that step will require - // that the archival task (DumpSetup) has seen the new disks and added - // any debug datasets found on them. + // that the archival task (DebugCollector) has seen the new disks and + // added any debug datasets found on them. self.update_output_watch_channels(); // For any newly-adopted disks, clean up any former zone root datasets diff --git a/sled-agent/config-reconciler/src/reconciler_task/zones.rs b/sled-agent/config-reconciler/src/reconciler_task/zones.rs index 958c507286f..ebd18f84345 100644 --- a/sled-agent/config-reconciler/src/reconciler_task/zones.rs +++ b/sled-agent/config-reconciler/src/reconciler_task/zones.rs @@ -11,7 +11,7 @@ use crate::InternalDisks; use crate::ResolverStatusExt; use crate::SledAgentFacilities; use crate::TimeSyncConfig; -use crate::dump_setup_task::FormerZoneRootArchiver; +use crate::debug_collector_task::FormerZoneRootArchiver; use camino::Utf8PathBuf; use futures::FutureExt as _; use futures::future; diff --git a/sled-agent/src/zone_bundle.rs b/sled-agent/src/zone_bundle.rs index 86c854d6445..29c095cab24 100644 --- a/sled-agent/src/zone_bundle.rs +++ b/sled-agent/src/zone_bundle.rs @@ -670,7 +670,8 @@ async fn create_snapshot( // A key feature of the zone-bundle process is that we pull all the log files // for a zone. This is tricky. The logs are both being written to by the // programs we're interested in, and also potentially being rotated by `logadm`, -// and / or archived out to the U.2s through the code in `crate::dump_setup`. +// and / or archived out to the U.2s through the code in +// `crate::debug_collector`. // // We need to capture all these logs, while avoiding inconsistent state (e.g., a // missing log message that existed when the bundle was created) and also @@ -1033,8 +1034,8 @@ async fn create( // // Both of these are dynamic. The current log file is likely being written // by the service itself, and `logadm` may also be rotating files. At the - // same time, the log-archival process in `dump_setup.rs` may be copying - // these out to the U.2s, after which it deletes those on the zone + // same time, the log-archival process in `debug_collector.rs` may be + // copying these out to the U.2s, after which it deletes those on the zone // filesystem itself. // // To avoid various kinds of corruption, such as a bad tarball or missing @@ -1261,7 +1262,7 @@ async fn find_archived_log_files<'a, T: Iterator>( } } } else { - // The logic in `dump_setup` picks some U.2 in which to start + // The logic in `debug_collector` picks some U.2 in which to start // archiving logs, and thereafter tries to keep placing new ones // there, subject to space constraints. It's not really an error for // there to be no entries for the named zone in any particular U.2 diff --git a/sled-agent/types/src/support_bundle.rs b/sled-agent/types/src/support_bundle.rs index ab31feb735d..42fff3374bc 100644 --- a/sled-agent/types/src/support_bundle.rs +++ b/sled-agent/types/src/support_bundle.rs @@ -13,9 +13,9 @@ // | | This is a per-bundle nested dataset // | This is a Debug dataset // -// NOTE: The "DumpSetupWorker" has been explicitly configured to ignore these files, so they are -// not removed. If the files used here change in the future, DumpSetupWorker should also be -// updated. +// NOTE: The DebugCollector has been explicitly configured to ignore these +// files, so they are not removed. If the files used here change in the future, +// DebugCollector should also be updated. pub const BUNDLE_FILE_NAME: &str = "bundle.zip"; pub const BUNDLE_TMP_FILE_NAME: &str = "bundle.zip.tmp";