Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/hyperqueue/src/client/commands/autoalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ wasted allocation duration."
detect_resources,
no_hyper_threading,
idle_timeout,
heartbeat,
overview_interval,
min_utilization,
} = worker_args;
Expand Down Expand Up @@ -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([
Expand Down
23 changes: 13 additions & 10 deletions crates/hyperqueue/src/client/commands/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -137,6 +141,13 @@ pub struct SharedWorkerStartOpts {
)]
pub idle_timeout: Option<Duration>,

#[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<Duration>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there Option here? Why not pub heartbeat: Duration (+ default_value = "8s") as it was before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is mirroring idle_timeout above. Probably minor, but this way the default is not baked in at queue creation time instead of letting the worker apply it's own default at start time


/// The period of reporting the overview to the server
///
/// The overview contains information about HW usage.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -334,10 +337,10 @@ fn gather_configuration(opts: WorkerStartOpts) -> anyhow::Result<WorkerConfigura
detect_resources: detect_resources_cli,
no_hyper_threading,
idle_timeout,
heartbeat,
overview_interval,
min_utilization,
},
heartbeat,
time_limit,
manager,
hostname,
Expand Down Expand Up @@ -465,7 +468,7 @@ fn gather_configuration(opts: WorkerStartOpts) -> anyhow::Result<WorkerConfigura
group,
work_dir,
on_server_lost: on_server_lost.into(),
heartbeat_interval: heartbeat,
heartbeat_interval: heartbeat.unwrap_or(DEFAULT_HEARTBEAT_INTERVAL),
idle_timeout,
overview_configuration,
extra,
Expand Down