Skip to content

Commit f0ea406

Browse files
committed
feat: run containerdebug in the background
1 parent c206b5d commit f0ea406

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

rust/operator-binary/src/history/history_controller.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,13 @@ fn build_stateful_set(
527527
.context(InvalidContainerNameSnafu)?
528528
.image_from_product_image(resolved_product_image)
529529
.resources(merged_config.resources.clone().into())
530-
.command(vec!["/bin/bash".to_string()])
530+
.command(vec![
531+
"/bin/bash".to_string(),
532+
"-x".to_string(),
533+
"-euo".to_string(),
534+
"pipefail".to_string(),
535+
"-c".to_string(),
536+
])
531537
.args(command_args(log_dir))
532538
.add_container_port("http", 18080)
533539
.add_container_port("metrics", METRICS_PORT.into())
@@ -751,10 +757,10 @@ fn command_args(logdir: &ResolvedLogDir) -> Vec<String> {
751757
}
752758

753759
command.extend(vec![
760+
format!("CONTAINERDEBUG_LOG_DIRECTORY={VOLUME_MOUNT_PATH_LOG}/containerdebug containerdebug --output={VOLUME_MOUNT_PATH_LOG}/containerdebug-state.json --loop &"),
754761
format!("/stackable/spark/sbin/start-history-server.sh --properties-file {VOLUME_MOUNT_PATH_CONFIG}/{SPARK_DEFAULTS_FILE_NAME}"),
755762
]);
756-
757-
vec![String::from("-c"), command.join(" && ")]
763+
vec![command.join("\n")]
758764
}
759765

760766
fn labels<'a, T>(

rust/operator-binary/src/spark_k8s_controller.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,11 @@ fn pod_template(
594594
.resources(config.resources.clone().into())
595595
.image_from_product_image(spark_image);
596596

597+
cb.add_env_var(
598+
"_STACKABLE_PRE_HOOK",
599+
format!("CONTAINERDEBUG_LOG_DIRECTORY={VOLUME_MOUNT_PATH_LOG}/containerdebug containerdebug --output={VOLUME_MOUNT_PATH_LOG}/containerdebug-state.json --loop &"),
600+
);
601+
597602
if config.logging.enable_vector_agent {
598603
cb.add_env_var(
599604
"_STACKABLE_POST_HOOK",

tests/templates/kuttl/smoke/06-assert.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ metadata:
99
name: spark-history-node-default
1010
status:
1111
readyReplicas: 1
12+
---
13+
# This test checks if the containerdebug-state.json file is present and valid
14+
apiVersion: kuttl.dev/v1beta1
15+
kind: TestAssert
16+
timeout: 600
17+
commands:
18+
- script: kubectl exec -n $NAMESPACE --container airflow spark-history-node-default-0 -- cat /stackable/log/containerdebug-state.json | jq --exit-status

tests/templates/kuttl/smoke/10-assert.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ metadata:
99
name: spark-pi-s3-1
1010
status:
1111
phase: Succeeded
12+
---
13+
# This test checks if the containerdebug-state.json file is present and valid
14+
apiVersion: kuttl.dev/v1beta1
15+
kind: TestAssert
16+
timeout: 600
17+
commands:
18+
- script: kubectl exec -n $NAMESPACE --container airflow spark-history-node-default-0 -- cat /stackable/log/containerdebug-state.json | jq --exit-status

0 commit comments

Comments
 (0)