@@ -83,9 +83,11 @@ const USER_INFO_FETCHER_KERBEROS_DIR: &str = "/stackable/kerberos";
8383stackable_operator:: constant!( TLS_VOLUME_NAME : VolumeName = "tls" ) ;
8484const TLS_STORE_DIR : & str = "/stackable/tls" ;
8585
86- // HTTP probe configuration shared by the bundle-builder and OPA containers. Both expose a
87- // `/status` endpoint; only the port (and, for OPA, the URI scheme) differ.
88- const PROBE_PATH : & str = "/status" ;
86+ // HTTP probe configuration shared by the bundle-builder and OPA containers. They differ in the
87+ // probed path (the bundle-builder exposes `/status`, OPA's HTTP server answers `/`), the port and,
88+ // for OPA, the URI scheme.
89+ const BUNDLE_BUILDER_PROBE_PATH : & str = "/status" ;
90+ const OPA_PROBE_PATH : & str = "/" ;
8991const PROBE_PERIOD_SECONDS : i32 = 10 ;
9092const READINESS_PROBE_INITIAL_DELAY_SECONDS : i32 = 5 ;
9193const READINESS_PROBE_FAILURE_THRESHOLD : i32 = 5 ;
@@ -190,30 +192,30 @@ fn bash_entrypoint_command() -> Vec<String> {
190192 . collect ( )
191193}
192194
193- /// An HTTP readiness [`Probe`] against the `/status` endpoint on the given `port`/`scheme`.
194- fn http_status_readiness_probe ( port : IntOrString , scheme : Option < String > ) -> Probe {
195+ /// An HTTP readiness [`Probe`] against `path` on the given `port`/`scheme`.
196+ fn http_readiness_probe ( path : & str , port : IntOrString , scheme : Option < String > ) -> Probe {
195197 Probe {
196198 initial_delay_seconds : Some ( READINESS_PROBE_INITIAL_DELAY_SECONDS ) ,
197199 period_seconds : Some ( PROBE_PERIOD_SECONDS ) ,
198200 failure_threshold : Some ( READINESS_PROBE_FAILURE_THRESHOLD ) ,
199201 http_get : Some ( HTTPGetAction {
200202 port,
201- path : Some ( PROBE_PATH . to_string ( ) ) ,
203+ path : Some ( path . to_string ( ) ) ,
202204 scheme,
203205 ..HTTPGetAction :: default ( )
204206 } ) ,
205207 ..Probe :: default ( )
206208 }
207209}
208210
209- /// An HTTP liveness [`Probe`] against the `/status` endpoint on the given `port`/`scheme`.
210- fn http_status_liveness_probe ( port : IntOrString , scheme : Option < String > ) -> Probe {
211+ /// An HTTP liveness [`Probe`] against `path` on the given `port`/`scheme`.
212+ fn http_liveness_probe ( path : & str , port : IntOrString , scheme : Option < String > ) -> Probe {
211213 Probe {
212214 initial_delay_seconds : Some ( LIVENESS_PROBE_INITIAL_DELAY_SECONDS ) ,
213215 period_seconds : Some ( PROBE_PERIOD_SECONDS ) ,
214216 http_get : Some ( HTTPGetAction {
215217 port,
216- path : Some ( PROBE_PATH . to_string ( ) ) ,
218+ path : Some ( path . to_string ( ) ) ,
217219 scheme,
218220 ..HTTPGetAction :: default ( )
219221 } ) ,
@@ -289,11 +291,13 @@ pub fn build_server_rolegroup_daemonset(
289291 . with_memory_limit ( "128Mi" )
290292 . build ( ) ,
291293 )
292- . readiness_probe ( http_status_readiness_probe (
294+ . readiness_probe ( http_readiness_probe (
295+ BUNDLE_BUILDER_PROBE_PATH ,
293296 IntOrString :: Int ( BUNDLE_BUILDER_PORT ) ,
294297 None ,
295298 ) )
296- . liveness_probe ( http_status_liveness_probe (
299+ . liveness_probe ( http_liveness_probe (
300+ BUNDLE_BUILDER_PROBE_PATH ,
297301 IntOrString :: Int ( BUNDLE_BUILDER_PORT ) ,
298302 None ,
299303 ) ) ;
@@ -348,11 +352,13 @@ pub fn build_server_rolegroup_daemonset(
348352 } ;
349353
350354 cb_opa
351- . readiness_probe ( http_status_readiness_probe (
355+ . readiness_probe ( http_readiness_probe (
356+ OPA_PROBE_PATH ,
352357 IntOrString :: String ( probe_port_name. to_string ( ) ) ,
353358 probe_scheme. clone ( ) ,
354359 ) )
355- . liveness_probe ( http_status_liveness_probe (
360+ . liveness_probe ( http_liveness_probe (
361+ OPA_PROBE_PATH ,
356362 IntOrString :: String ( probe_port_name. to_string ( ) ) ,
357363 probe_scheme,
358364 ) ) ;
@@ -842,8 +848,10 @@ fn build_prepare_start_command(merged_config: &OpaConfig, container_name: &str)
842848mod tests {
843849 use serde_json:: json;
844850 use stackable_operator:: {
845- commons:: networking:: DomainName , k8s_openapi:: api:: core:: v1:: ServiceAccount ,
846- k8s_openapi:: apimachinery:: pkg:: apis:: meta:: v1:: ObjectMeta ,
851+ commons:: networking:: DomainName ,
852+ k8s_openapi:: {
853+ api:: core:: v1:: ServiceAccount , apimachinery:: pkg:: apis:: meta:: v1:: ObjectMeta ,
854+ } ,
847855 } ;
848856
849857 use super :: * ;
@@ -998,6 +1006,35 @@ mod tests {
9981006 assert ! ( container_names( & ds) . contains( & "user-info-fetcher" . to_owned( ) ) ) ;
9991007 }
10001008
1009+ #[ test]
1010+ fn opa_probes_root_and_bundle_builder_probes_status ( ) {
1011+ let ds = build ( & validated_cluster_from_spec ( json ! ( {
1012+ "image" : { "productVersion" : "1.2.3" } ,
1013+ "servers" : { "roleGroups" : { "default" : { } } } ,
1014+ } ) ) ) ;
1015+ let pod_spec = ds. spec . as_ref ( ) . unwrap ( ) . template . spec . as_ref ( ) . unwrap ( ) ;
1016+ let liveness_path = |container : & str | -> String {
1017+ pod_spec
1018+ . containers
1019+ . iter ( )
1020+ . find ( |c| c. name == container)
1021+ . unwrap_or_else ( || panic ! ( "container {container} should exist" ) )
1022+ . liveness_probe
1023+ . as_ref ( )
1024+ . unwrap ( )
1025+ . http_get
1026+ . as_ref ( )
1027+ . unwrap ( )
1028+ . path
1029+ . clone ( )
1030+ . unwrap ( )
1031+ } ;
1032+ // OPA's HTTP server answers `/`; only the bundle-builder exposes `/status`. A wrong path
1033+ // here makes the liveness probe fail and the OPA container CrashLoop.
1034+ assert_eq ! ( liveness_path( "opa" ) , "/" ) ;
1035+ assert_eq ! ( liveness_path( "bundle-builder" ) , "/status" ) ;
1036+ }
1037+
10011038 #[ test]
10021039 fn daemonset_adds_tls_volume_when_tls_enabled ( ) {
10031040 let ds = build ( & validated_cluster_from_spec ( json ! ( {
0 commit comments