Skip to content

Commit be6ad1d

Browse files
authored
DEVPROD-14170 Add additional logging for long running task generation (#87)
1 parent 8746627 commit be6ad1d

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Changelog
2+
## 0.7.21 - 2025-01-16
3+
* Add additional logging for task generation that takes a long time.
24

35
## 0.7.20 - 2025-01-16
46
* DEVPROD-14172 Update shrub-rs dependency that includes papertrail.trace command

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mongo-task-generator"
33
description = "Dynamically split evergreen tasks into subtasks for testing the mongodb/mongo project."
44
license = "Apache-2.0"
5-
version = "0.7.20"
5+
version = "0.7.21"
66
repository = "https://github.com/mongodb/mongo-task-generator"
77
authors = ["Decision Automation Group <dev-prod-dag@mongodb.com>"]
88
edition = "2018"

src/lib.rs

+42
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use task_types::{
4343
resmoke_config_writer::{ResmokeConfigActor, ResmokeConfigActorService},
4444
resmoke_tasks::{GenResmokeConfig, GenResmokeTaskService, GenResmokeTaskServiceImpl},
4545
};
46+
use tokio::{runtime::Handle, task::JoinHandle, time};
4647
use tracing::{event, Level};
4748
use utils::fs_service::FsServiceImpl;
4849

@@ -434,6 +435,8 @@ impl GenerateTasksService for GenerateTasksServiceImpl {
434435
&self,
435436
deps: &Dependencies,
436437
) -> Result<Arc<Mutex<GenTaskCollection>>> {
438+
let _monitor = RemainingTaskMonitor::new();
439+
437440
let build_variant_list = self.evg_config_service.sort_build_variants_by_required();
438441
let build_variant_map = self.evg_config_service.get_build_variant_map();
439442
let task_map = Arc::new(self.evg_config_service.get_task_def_map());
@@ -533,6 +536,11 @@ impl GenerateTasksService for GenerateTasksServiceImpl {
533536
handle.await.unwrap();
534537
}
535538

539+
event!(
540+
Level::INFO,
541+
"Finished creating task definitions for all tasks."
542+
);
543+
536544
Ok(generated_tasks)
537545
}
538546

@@ -762,6 +770,11 @@ impl GenerateTasksService for GenerateTasksServiceImpl {
762770
}
763771
}
764772

773+
event!(
774+
Level::INFO,
775+
"Finished creating build variant definitions containing all the generated tasks."
776+
);
777+
765778
Ok(generated_build_variants)
766779
}
767780
}
@@ -804,6 +817,35 @@ fn lookup_task_name(
804817
}
805818
}
806819

820+
/// Runs a task that will periodically report the number of active tasks since the monitor was created.
821+
struct RemainingTaskMonitor {
822+
handle: JoinHandle<()>,
823+
}
824+
825+
impl RemainingTaskMonitor {
826+
pub fn new() -> Self {
827+
let metrics = Handle::current().metrics();
828+
let offset = metrics.num_alive_tasks() + 1; // + 1 to include the task spawned below.
829+
let handle = tokio::spawn(async move {
830+
loop {
831+
time::sleep(time::Duration::from_secs(60)).await;
832+
event!(
833+
Level::INFO,
834+
"Waiting on {} generate tasks to finish...",
835+
Handle::current().metrics().num_alive_tasks() - offset
836+
);
837+
}
838+
});
839+
840+
Self { handle }
841+
}
842+
}
843+
impl Drop for RemainingTaskMonitor {
844+
fn drop(&mut self) {
845+
self.handle.abort();
846+
}
847+
}
848+
807849
/// Spawn a tokio task to perform the task generation work.
808850
///
809851
/// # Arguments

0 commit comments

Comments
 (0)