Skip to content

Commit c5c5a7e

Browse files
committed
Use new ProbeBuilder
1 parent b49229c commit c5c5a7e

File tree

3 files changed

+38
-36
lines changed

3 files changed

+38
-36
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ strum = { version = "0.27", features = ["derive"] }
2929
tokio = { version = "1.40", features = ["full"] }
3030
tracing = "0.1"
3131

32-
# [patch."https://github.com/stackabletech/operator-rs"]
33-
# stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
32+
[patch."https://github.com/stackabletech/operator-rs"]
33+
stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "fix/probe-builder-clone" }
3434
# stackable-operator = { path = "../operator-rs/crates/stackable-operator" }

rust/operator-binary/src/superset_controller.rs

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use stackable_operator::{
2222
pod::{
2323
PodBuilder,
2424
container::ContainerBuilder,
25+
probe::ProbeBuilder,
2526
resources::ResourceRequirementsBuilder,
2627
security::PodSecurityContextBuilder,
2728
volume::{
@@ -40,9 +41,9 @@ use stackable_operator::{
4041
DeepMerge,
4142
api::{
4243
apps::v1::{StatefulSet, StatefulSetSpec},
43-
core::v1::{ConfigMap, EnvVar, HTTPGetAction, Probe},
44+
core::v1::{ConfigMap, EnvVar},
4445
},
45-
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
46+
apimachinery::pkg::apis::meta::v1::LabelSelector,
4647
},
4748
kube::{
4849
Resource, ResourceExt,
@@ -930,32 +931,33 @@ fn build_server_rolegroup_statefulset(
930931
}
931932

932933
fn add_superset_container_probes(superset_cb: &mut ContainerBuilder) {
933-
let probe_action = HTTPGetAction {
934-
port: IntOrString::Int(APP_PORT.into()),
935-
path: Some("/health".to_string()),
936-
..HTTPGetAction::default()
937-
};
938-
let common_probe = Probe {
939-
http_get: Some(probe_action),
940-
period_seconds: Some(5),
941-
timeout_seconds: Some(5),
942-
success_threshold: Some(1),
943-
..Probe::default()
944-
};
945-
superset_cb.startup_probe(Probe {
946-
failure_threshold: Some(10 /* minutes */ * 60 / 5),
947-
..common_probe.clone()
948-
});
934+
let common =
935+
ProbeBuilder::http_get_port_scheme_path(APP_PORT, None, Some("/health".to_owned()))
936+
.with_period(Duration::from_secs(5));
937+
938+
superset_cb.startup_probe(
939+
common
940+
.clone()
941+
.with_failure_threshold_duration(Duration::from_minutes_unchecked(10))
942+
.expect("static period is always non-zero")
943+
.build()
944+
.expect("static durations are not too long"),
945+
);
946+
949947
// Remove it from the Service immediately
950-
superset_cb.readiness_probe(Probe {
951-
failure_threshold: Some(1),
952-
..common_probe.clone()
953-
});
948+
superset_cb.readiness_probe(
949+
common
950+
.clone()
951+
.build()
952+
.expect("static durations are not too long"),
953+
);
954954
// But only restart it after 3 failures
955-
superset_cb.readiness_probe(Probe {
956-
failure_threshold: Some(3),
957-
..common_probe
958-
});
955+
superset_cb.liveness_probe(
956+
common
957+
.with_failure_threshold(3)
958+
.build()
959+
.expect("static durations are not too long"),
960+
);
959961
}
960962

961963
fn add_authentication_volumes_and_volume_mounts(

0 commit comments

Comments
 (0)