diff --git a/crates/hyperqueue/src/client/commands/autoalloc.rs b/crates/hyperqueue/src/client/commands/autoalloc.rs index 9470d51ba..38dcecb94 100644 --- a/crates/hyperqueue/src/client/commands/autoalloc.rs +++ b/crates/hyperqueue/src/client/commands/autoalloc.rs @@ -327,6 +327,7 @@ wasted allocation duration." detect_resources, no_hyper_threading, idle_timeout, + heartbeat, overview_interval, min_utilization, } = worker_args; @@ -372,6 +373,12 @@ wasted allocation duration." format!("\"{}\"", overview_interval.into_original_input()), ]); } + if let Some(heartbeat) = heartbeat { + worker_args.extend([ + "--heartbeat".to_string(), + format!("\"{}\"", format_duration(heartbeat)), + ]); + } if min_utilization > 0.0 { worker_args.extend([ diff --git a/crates/hyperqueue/src/client/commands/worker.rs b/crates/hyperqueue/src/client/commands/worker.rs index d71063ae3..aa8414ea4 100644 --- a/crates/hyperqueue/src/client/commands/worker.rs +++ b/crates/hyperqueue/src/client/commands/worker.rs @@ -49,6 +49,10 @@ use crate::worker::parser::{ use crate::{DEFAULT_WORKER_GROUP_NAME, rpc_call}; use tako::WorkerId; +/// Default worker heartbeat interval, applied when `--heartbeat` is not passed +/// (both for `hq worker start` and for `hq alloc add` pilot workers). +const DEFAULT_HEARTBEAT_INTERVAL: Duration = Duration::from_secs(8); + #[derive(clap::ValueEnum, Clone)] pub enum WorkerFilter { Running, @@ -137,6 +141,13 @@ pub struct SharedWorkerStartOpts { )] pub idle_timeout: Option, + #[arg( + long, + value_parser = parse_hms_or_human_time, + help = duration_doc!("How often heartbeats are sent\n\nHeartbeats are used to detect worker's liveness. If the worker does not send a heartbeat for given time, then the worker is considered as lost.\n\nDefaults to 8s.") + )] + pub heartbeat: Option, + /// The period of reporting the overview to the server /// /// The overview contains information about HW usage. @@ -251,14 +262,6 @@ pub struct WorkerStartOpts { #[clap(flatten)] shared: SharedWorkerStartOpts, - #[arg( - long, - default_value = "8s", - value_parser = parse_hms_or_human_time, - help = duration_doc!("How often heartbeats are sent\n\nHeartbeats are used to detect worker's liveness. If the worker does not send a heartbeat for given time, then the worker is considered as lost.") - )] - pub heartbeat: Duration, - #[arg( long, value_parser = parse_hms_or_human_time, @@ -334,10 +337,10 @@ fn gather_configuration(opts: WorkerStartOpts) -> anyhow::Result anyhow::Result