Skip to content

Commit

Permalink
DEVPROD-14170 Add additional logging for long running task generation (
Browse files Browse the repository at this point in the history
  • Loading branch information
sleaux authored Jan 21, 2025
1 parent 8746627 commit be6ad1d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
edition = "2018"
Expand Down
42 changes: 42 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -434,6 +435,8 @@ impl GenerateTasksService for GenerateTasksServiceImpl {
&self,
deps: &Dependencies,
) -> Result<Arc<Mutex<GenTaskCollection>>> {
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());
Expand Down Expand Up @@ -533,6 +536,11 @@ impl GenerateTasksService for GenerateTasksServiceImpl {
handle.await.unwrap();
}

event!(
Level::INFO,
"Finished creating task definitions for all tasks."
);

Ok(generated_tasks)
}

Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit be6ad1d

Please sign in to comment.