diff --git a/antlir/antlir2/antlir2/BUCK b/antlir/antlir2/antlir2/BUCK index 419e4264f2..9695641ac8 100644 --- a/antlir/antlir2/antlir2/BUCK +++ b/antlir/antlir2/antlir2/BUCK @@ -14,7 +14,6 @@ rust_binary( "serde_json", "thiserror", "tracing", - "tracing-glog", "tracing-subscriber", "//antlir:find_root", "//antlir/antlir2/antlir2_btrfs:antlir2_btrfs", diff --git a/antlir/antlir2/antlir2/src/cmd/compile.rs b/antlir/antlir2/antlir2/src/cmd/compile.rs index 4dab491f5d..8c3904a0b8 100644 --- a/antlir/antlir2/antlir2/src/cmd/compile.rs +++ b/antlir/antlir2/antlir2/src/cmd/compile.rs @@ -53,7 +53,7 @@ impl Compile { } impl Compile { - #[tracing::instrument(name = "compile", skip(self))] + #[tracing::instrument(name = "compile", skip(self), ret, err)] pub(crate) fn run(self) -> Result<()> { let ctx = self .compileish diff --git a/antlir/antlir2/antlir2/src/cmd/map.rs b/antlir/antlir2/antlir2/src/cmd/map.rs index bcc765cb85..8ed742ab39 100644 --- a/antlir/antlir2/antlir2/src/cmd/map.rs +++ b/antlir/antlir2/antlir2/src/cmd/map.rs @@ -109,7 +109,7 @@ impl Subcommand { impl Map { /// Create a new mutable subvolume based on the [SetupArgs]. - #[tracing::instrument(skip(self), ret, err)] + #[tracing::instrument(skip(self, rootless), ret, err)] fn create_new_subvol( &self, working_volume: &WorkingVolume, @@ -136,7 +136,7 @@ impl Map { Ok(subvol) } - #[tracing::instrument(name = "map", skip(self))] + #[tracing::instrument(name = "map", skip_all, ret, err)] pub(crate) fn run( self, log_path: Option<&Path>, diff --git a/antlir/antlir2/antlir2/src/main.rs b/antlir/antlir2/antlir2/src/main.rs index 34c5bafda7..3b5bdffba2 100644 --- a/antlir/antlir2/antlir2/src/main.rs +++ b/antlir/antlir2/antlir2/src/main.rs @@ -113,23 +113,10 @@ fn main() -> Result<()> { let args = Args::parse(); tracing_subscriber::registry() - .with( - tracing_subscriber::fmt::Layer::default() - .event_format( - tracing_glog::Glog::default() - .with_span_context(true) - .with_timer(tracing_glog::LocalTime::default()), - ) - .fmt_fields(tracing_glog::GlogFields::default()), - ) + .with(tracing_subscriber::fmt::Layer::default().with_ansi(false)) .with(args.log.file()?.map(|file| { tracing_subscriber::fmt::Layer::default() - .event_format( - tracing_glog::Glog::default() - .with_span_context(true) - .with_timer(tracing_glog::LocalTime::default()), - ) - .fmt_fields(tracing_glog::GlogFields::default()) + .with_ansi(false) .with_writer(file) })) .init(); diff --git a/antlir/antlir2/antlir2_working_volume/src/lib.rs b/antlir/antlir2/antlir2_working_volume/src/lib.rs index fb985fded5..b28bbab254 100644 --- a/antlir/antlir2/antlir2_working_volume/src/lib.rs +++ b/antlir/antlir2/antlir2_working_volume/src/lib.rs @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +use std::fmt::Debug; use std::fs::File; use std::io::ErrorKind; use std::os::fd::AsRawFd; @@ -25,6 +26,7 @@ use nix::fcntl::OFlag; use nix::sys::stat::Mode; use serde::Deserialize; use tracing::trace; +use tracing::trace_span; use tracing::warn; use uuid::Uuid; @@ -53,12 +55,20 @@ pub struct WorkingVolume { eden: Option, } -#[derive(Debug, Clone)] +#[derive(Clone)] struct EdenInfo { repo_root: PathBuf, redirections: Vec, } +impl Debug for EdenInfo { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("EdenInfo") + .field("repo_root", &self.repo_root) + .finish_non_exhaustive() + } +} + #[derive(Debug, Clone, Deserialize)] struct EdenRedirection { repo_path: PathBuf, @@ -210,6 +220,9 @@ impl WorkingVolume { for entry in std::fs::read_dir(&self.path)? { let entry = entry?; if entry.path().is_dir() { + let span = + trace_span!("collect_garbage", path = entry.path().display().to_string()); + let _guard = span.enter(); // skip outputs that are very new to avoid any race condition // between creating the output and setting the keepalive if let Ok(mtime) = entry.metadata().and_then(|meta| meta.modified()) { @@ -228,10 +241,12 @@ impl WorkingVolume { }, }?; if delete { - trace!("{} is no longer referenced", entry.path().display()); + trace!("subvol is no longer referenced"); try_delete_subvol(&entry.path()); if let Err(e) = std::fs::remove_file(&keepalive_path) { - warn!("failed to remove keepalive file: {e}"); + if e.kind() != std::io::ErrorKind::NotFound { + warn!("failed to remove keepalive file: {e}"); + } } } }