Skip to content

Commit ac6dc70

Browse files
chore: Switch liveness probe to tcp socket instead of httpGet (#637)
* chore: Switch WebUI liveness probe to tcp socket instead of httpGet * cleanup * Update rust/operator-binary/src/container.rs Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> --------- Co-authored-by: Siegfried Weber <mail@siegfriedweber.net>
1 parent a49b429 commit ac6dc70

File tree

2 files changed

+39
-51
lines changed

2 files changed

+39
-51
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ All notable changes to this project will be documented in this file.
1010
config property `requestedSecretLifetime`. This helps reducing frequent Pod restarts ([#619]).
1111
- Run a `containerdebug` process in the background of each HDFS container to collect debugging information ([#629]).
1212

13+
### Changed
14+
15+
- Switch the WebUI liveness probe from `httpGet` to checking the tcp socket.
16+
This helps with setups where configOverrides are used to enable security on the HTTP interfaces.
17+
As this results in `401` HTTP responses (instead of `200`), this previously failed the liveness checks.
18+
1319
### Fixed
1420

1521
- BREAKING: Use distinct ServiceAccounts for the Stacklets, so that multiple Stacklets can be

rust/operator-binary/src/container.rs

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ use stackable_operator::{
4545
k8s_openapi::{
4646
api::core::v1::{
4747
ConfigMapKeySelector, ConfigMapVolumeSource, Container, ContainerPort,
48-
EmptyDirVolumeSource, EnvVar, EnvVarSource, HTTPGetAction, ObjectFieldSelector,
49-
PersistentVolumeClaim, Probe, ResourceRequirements, TCPSocketAction, Volume,
50-
VolumeMount,
48+
EmptyDirVolumeSource, EnvVar, EnvVarSource, ObjectFieldSelector, PersistentVolumeClaim,
49+
Probe, ResourceRequirements, TCPSocketAction, Volume, VolumeMount,
5150
},
5251
apimachinery::pkg::util::intstr::IntOrString,
5352
},
@@ -158,15 +157,6 @@ pub enum ContainerConfig {
158157
web_ui_http_port_name: &'static str,
159158
/// Port name of the web UI HTTPS port, used for the liveness probe.
160159
web_ui_https_port_name: &'static str,
161-
/// Path of the web UI URL; The path defaults to / in Kubernetes
162-
/// and the kubelet follows redirects. The default would work if
163-
/// the location header is set properly but that is not the case
164-
/// for the DataNode. On a TLS-enabled DataNode, calling
165-
/// https://127.0.0.1:9865/ redirects to the non-TLS URL
166-
/// http://127.0.0.1:9865/index.html which causes the liveness
167-
/// probe to fail. So it is best to not rely on the location
168-
/// header but instead provide the resolved path directly.
169-
web_ui_path: &'static str,
170160
/// The JMX Exporter metrics port.
171161
metrics_port: u16,
172162
},
@@ -958,38 +948,29 @@ wait_for_termination $!
958948
initial_delay_seconds: i32,
959949
failure_threshold: i32,
960950
) -> Option<Probe> {
961-
match self {
962-
ContainerConfig::Hdfs {
963-
web_ui_http_port_name,
964-
web_ui_https_port_name,
965-
web_ui_path,
966-
..
967-
} => {
968-
let http_get_action = if hdfs.has_https_enabled() {
969-
HTTPGetAction {
970-
port: IntOrString::String(web_ui_https_port_name.to_string()),
971-
scheme: Some("HTTPS".into()),
972-
path: Some(web_ui_path.to_string()),
973-
..HTTPGetAction::default()
974-
}
975-
} else {
976-
HTTPGetAction {
977-
port: IntOrString::String(web_ui_http_port_name.to_string()),
978-
scheme: Some("HTTP".into()),
979-
path: Some(web_ui_path.to_string()),
980-
..HTTPGetAction::default()
981-
}
982-
};
983-
Some(Probe {
984-
http_get: Some(http_get_action),
985-
period_seconds: Some(period_seconds),
986-
initial_delay_seconds: Some(initial_delay_seconds),
987-
failure_threshold: Some(failure_threshold),
988-
..Probe::default()
989-
})
990-
}
991-
_ => None,
992-
}
951+
let ContainerConfig::Hdfs {
952+
web_ui_http_port_name,
953+
web_ui_https_port_name,
954+
..
955+
} = self
956+
else {
957+
return None;
958+
};
959+
960+
let port = if hdfs.has_https_enabled() {
961+
web_ui_https_port_name
962+
} else {
963+
web_ui_http_port_name
964+
};
965+
966+
Some(Probe {
967+
// Use tcp_socket instead of http_get so that the probe is independent of the authentication settings.
968+
tcp_socket: Some(Self::tcp_socket_action_for_port(*port)),
969+
period_seconds: Some(period_seconds),
970+
initial_delay_seconds: Some(initial_delay_seconds),
971+
failure_threshold: Some(failure_threshold),
972+
..Probe::default()
973+
})
993974
}
994975

995976
/// Creates a probe for the IPC/RPC port
@@ -1001,10 +982,7 @@ wait_for_termination $!
1001982
) -> Option<Probe> {
1002983
match self {
1003984
ContainerConfig::Hdfs { ipc_port_name, .. } => Some(Probe {
1004-
tcp_socket: Some(TCPSocketAction {
1005-
port: IntOrString::String(ipc_port_name.to_string()),
1006-
..TCPSocketAction::default()
1007-
}),
985+
tcp_socket: Some(Self::tcp_socket_action_for_port(*ipc_port_name)),
1008986
period_seconds: Some(period_seconds),
1009987
initial_delay_seconds: Some(initial_delay_seconds),
1010988
failure_threshold: Some(failure_threshold),
@@ -1014,6 +992,13 @@ wait_for_termination $!
1014992
}
1015993
}
1016994

995+
fn tcp_socket_action_for_port(port: impl Into<String>) -> TCPSocketAction {
996+
TCPSocketAction {
997+
port: IntOrString::String(port.into()),
998+
..Default::default()
999+
}
1000+
}
1001+
10171002
/// Return the container volumes.
10181003
fn volumes(
10191004
&self,
@@ -1390,7 +1375,6 @@ impl From<HdfsRole> for ContainerConfig {
13901375
ipc_port_name: SERVICE_PORT_NAME_RPC,
13911376
web_ui_http_port_name: SERVICE_PORT_NAME_HTTP,
13921377
web_ui_https_port_name: SERVICE_PORT_NAME_HTTPS,
1393-
web_ui_path: "/dfshealth.html",
13941378
metrics_port: DEFAULT_NAME_NODE_METRICS_PORT,
13951379
},
13961380
HdfsRole::DataNode => Self::Hdfs {
@@ -1400,7 +1384,6 @@ impl From<HdfsRole> for ContainerConfig {
14001384
ipc_port_name: SERVICE_PORT_NAME_IPC,
14011385
web_ui_http_port_name: SERVICE_PORT_NAME_HTTP,
14021386
web_ui_https_port_name: SERVICE_PORT_NAME_HTTPS,
1403-
web_ui_path: "/datanode.html",
14041387
metrics_port: DEFAULT_DATA_NODE_METRICS_PORT,
14051388
},
14061389
HdfsRole::JournalNode => Self::Hdfs {
@@ -1410,7 +1393,6 @@ impl From<HdfsRole> for ContainerConfig {
14101393
ipc_port_name: SERVICE_PORT_NAME_RPC,
14111394
web_ui_http_port_name: SERVICE_PORT_NAME_HTTP,
14121395
web_ui_https_port_name: SERVICE_PORT_NAME_HTTPS,
1413-
web_ui_path: "/journalnode.html",
14141396
metrics_port: DEFAULT_JOURNAL_NODE_METRICS_PORT,
14151397
},
14161398
}

0 commit comments

Comments
 (0)