diff --git a/CHANGELOG.md b/CHANGELOG.md index 11f410f..9feb7b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # Changelog +## 0.7.21 - 2025-01-16 +* Add additional logging for task generation that takes a long time. ## 0.7.20 - 2025-01-16 * DEVPROD-14172 Update shrub-rs dependency that includes papertrail.trace command diff --git a/Cargo.lock b/Cargo.lock index 39f92aa..67a1b19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1635,7 +1635,7 @@ dependencies = [ [[package]] name = "mongo-task-generator" -version = "0.7.20" +version = "0.7.21" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index dddc43f..e5dbbe9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "mongo-task-generator" description = "Dynamically split evergreen tasks into subtasks for testing the mongodb/mongo project." license = "Apache-2.0" -version = "0.7.20" +version = "0.7.21" repository = "https://github.com/mongodb/mongo-task-generator" authors = ["Decision Automation Group "] edition = "2018" diff --git a/src/lib.rs b/src/lib.rs index 6566b89..9ffcd56 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,6 +43,7 @@ use task_types::{ resmoke_config_writer::{ResmokeConfigActor, ResmokeConfigActorService}, resmoke_tasks::{GenResmokeConfig, GenResmokeTaskService, GenResmokeTaskServiceImpl}, }; +use tokio::{runtime::Handle, task::JoinHandle, time}; use tracing::{event, Level}; use utils::fs_service::FsServiceImpl; @@ -434,6 +435,8 @@ impl GenerateTasksService for GenerateTasksServiceImpl { &self, deps: &Dependencies, ) -> Result>> { + let _monitor = RemainingTaskMonitor::new(); + let build_variant_list = self.evg_config_service.sort_build_variants_by_required(); let build_variant_map = self.evg_config_service.get_build_variant_map(); let task_map = Arc::new(self.evg_config_service.get_task_def_map()); @@ -533,6 +536,11 @@ impl GenerateTasksService for GenerateTasksServiceImpl { handle.await.unwrap(); } + event!( + Level::INFO, + "Finished creating task definitions for all tasks." + ); + Ok(generated_tasks) } @@ -762,6 +770,11 @@ impl GenerateTasksService for GenerateTasksServiceImpl { } } + event!( + Level::INFO, + "Finished creating build variant definitions containing all the generated tasks." + ); + Ok(generated_build_variants) } } @@ -804,6 +817,35 @@ fn lookup_task_name( } } +/// Runs a task that will periodically report the number of active tasks since the monitor was created. +struct RemainingTaskMonitor { + handle: JoinHandle<()>, +} + +impl RemainingTaskMonitor { + pub fn new() -> Self { + let metrics = Handle::current().metrics(); + let offset = metrics.num_alive_tasks() + 1; // + 1 to include the task spawned below. + let handle = tokio::spawn(async move { + loop { + time::sleep(time::Duration::from_secs(60)).await; + event!( + Level::INFO, + "Waiting on {} generate tasks to finish...", + Handle::current().metrics().num_alive_tasks() - offset + ); + } + }); + + Self { handle } + } +} +impl Drop for RemainingTaskMonitor { + fn drop(&mut self) { + self.handle.abort(); + } +} + /// Spawn a tokio task to perform the task generation work. /// /// # Arguments