Skip to content

Commit 20cb306

Browse files
authored
perf(docker): slow steady-state supervisor healthcheck (#4802)
Signed-off-by: Yuedong Wu <[email protected]>
1 parent 4b7486e commit 20cb306

2 files changed

Lines changed: 31 additions & 15 deletions

File tree

‎crates/openshell-driver-docker/src/lib.rs‎

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ const WATCH_POLL_MAX_BACKOFF: Duration = Duration::from_secs(30);
9494
// request a bounded opportunity to mark the control exit intentional before
9595
// publishing a fail-closed runtime error.
9696
const SUPERVISOR_INTENTIONAL_SHUTDOWN_GRACE: Duration = Duration::from_secs(1);
97-
const SUPERVISOR_HEALTH_INTERVAL_NS: i64 = 250_000_000;
97+
const SUPERVISOR_HEALTH_INTERVAL_NS: i64 = 30_000_000_000;
98+
// Docker probes at this interval only before the first healthy result and
99+
// within the start period.
100+
const SUPERVISOR_HEALTH_START_INTERVAL_NS: i64 = 250_000_000;
98101
const SUPERVISOR_HEALTH_TIMEOUT_NS: i64 = 2_000_000_000;
99102
const SUPERVISOR_HEALTH_START_PERIOD_NS: i64 = 60_000_000_000;
100103
const HOST_GATEWAY_RESOLUTION_TIMEOUT: Duration = Duration::from_secs(30);
@@ -5127,6 +5130,23 @@ fn docker_auxiliary_container_labels(
51275130
])
51285131
}
51295132

5133+
fn docker_supervisor_healthcheck() -> HealthConfig {
5134+
HealthConfig {
5135+
test: Some(vec![
5136+
"CMD".to_string(),
5137+
SUPERVISOR_IMAGE_CONTROL_BINARY_PATH.to_string(),
5138+
"health".to_string(),
5139+
"--socket".to_string(),
5140+
SUPERVISOR_HEALTH_SOCKET_PATH.to_string(),
5141+
]),
5142+
interval: Some(SUPERVISOR_HEALTH_INTERVAL_NS),
5143+
timeout: Some(SUPERVISOR_HEALTH_TIMEOUT_NS),
5144+
retries: Some(3),
5145+
start_period: Some(SUPERVISOR_HEALTH_START_PERIOD_NS),
5146+
start_interval: Some(SUPERVISOR_HEALTH_START_INTERVAL_NS),
5147+
}
5148+
}
5149+
51305150
fn docker_supervisor_host_config(
51315151
mounts: Vec<Mount>,
51325152
grpc_endpoint: &str,
@@ -5375,20 +5395,7 @@ async fn spawn_docker_control_process(
53755395
cmd: Some(command),
53765396
env: Some(environment),
53775397
labels: Some(labels),
5378-
healthcheck: Some(HealthConfig {
5379-
test: Some(vec![
5380-
"CMD".to_string(),
5381-
SUPERVISOR_IMAGE_CONTROL_BINARY_PATH.to_string(),
5382-
"health".to_string(),
5383-
"--socket".to_string(),
5384-
SUPERVISOR_HEALTH_SOCKET_PATH.to_string(),
5385-
]),
5386-
interval: Some(SUPERVISOR_HEALTH_INTERVAL_NS),
5387-
timeout: Some(SUPERVISOR_HEALTH_TIMEOUT_NS),
5388-
retries: Some(3),
5389-
start_period: Some(SUPERVISOR_HEALTH_START_PERIOD_NS),
5390-
start_interval: Some(SUPERVISOR_HEALTH_INTERVAL_NS),
5391-
}),
5398+
healthcheck: Some(docker_supervisor_healthcheck()),
53925399
host_config: Some(docker_supervisor_host_config(
53935400
supervisor_mounts,
53945401
&supervisor_endpoint,

‎crates/openshell-driver-docker/src/tests.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,6 +3226,15 @@ fn docker_supervisor_leaves_named_gateway_hosts_to_dns() {
32263226
);
32273227
}
32283228

3229+
#[test]
3230+
fn docker_supervisor_healthcheck_probes_fast_only_during_startup() {
3231+
let health = docker_supervisor_healthcheck();
3232+
3233+
assert_eq!(health.start_interval, Some(250_000_000));
3234+
assert_eq!(health.interval, Some(30_000_000_000));
3235+
assert_eq!(health.start_period, Some(60_000_000_000));
3236+
}
3237+
32293238
#[test]
32303239
fn docker_supervisor_defaults_to_the_primary_loopback_endpoint() {
32313240
assert_eq!(

0 commit comments

Comments
 (0)