Skip to content

Commit

Permalink
reintroduce the CONTAINERDEBUG_LOG_DIRECTORY env var
Browse files Browse the repository at this point in the history
  • Loading branch information
razvan committed Dec 14, 2024
1 parent 3333172 commit 6008a8f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
10 changes: 10 additions & 0 deletions rust/crd/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ impl SparkHistoryServer {
let mut vars: BTreeMap<String, EnvVar> = BTreeMap::new();
let role_env_overrides = &self.role().config.env_overrides;

// Needed by the `containerdebug` running in the background of the history container
// to log it's tracing information to.
vars.insert(
"CONTAINERDEBUG_LOG_DIRECTORY".to_string(),
EnvVar {
name: "CONTAINERDEBUG_LOG_DIRECTORY".to_string(),
value: Some(format!("{VOLUME_MOUNT_PATH_LOG}/containerdebug")),
value_from: None,
},
);
// This env var prevents the history server from detaching itself from the
// start script because this leads to the Pod terminating immediately.
vars.insert(
Expand Down
9 changes: 9 additions & 0 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,15 @@ impl SparkApplication {
logdir: &Option<ResolvedLogDir>,
) -> Vec<EnvVar> {
let mut e: Vec<EnvVar> = self.spec.env.clone();

// Needed by the `containerdebug` process running in the background of the `spark-submit`
// container to log it's tracing information to.
e.push(EnvVar {
name: "CONTAINERDEBUG_LOG_DIRECTORY".to_string(),
value: Some(format!("{VOLUME_MOUNT_PATH_LOG}/containerdebug")),
value_from: None,
});

if self.requirements().is_some() {
e.push(EnvVar {
name: "PYTHONPATH".to_string(),
Expand Down
26 changes: 22 additions & 4 deletions rust/operator-binary/src/spark_k8s_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,29 @@ fn pod_template(
.resources(config.resources.clone().into())
.image_from_product_image(spark_image);

cb.add_env_var(
"_STACKABLE_PRE_HOOK",
format!(
// These env variables enable the `containerdebug` process in driver and executor pods.
// More precisely, this process runs in the background of every `spark` container.
// - `CONTAINERDEBUG_LOG_DIRECTORY` - is the location where tracing information from the process
// is written. This directory is created by the process it's self.
// - `_STACKABLE_PRE_HOOK` - is evaluated by the entrypoint script (run-spark.sh) in the Spark images
// before the actual JVM process is started. The result of this evaluation is that the
// `containerdebug` process is executed in the background.
cb.add_env_vars(
[
EnvVar {
name: "CONTAINERDEBUG_LOG_DIRECTORY".into(),
value: Some(format!("{VOLUME_MOUNT_PATH_LOG}/containerdebug")),
value_from: None,
},
EnvVar {
name: "_STACKABLE_PRE_HOOK".into(),
value: Some(format!(
"containerdebug --output={VOLUME_MOUNT_PATH_LOG}/containerdebug-state.json --loop &"
),
)),
value_from: None,
},
]
.into(),
);

if config.logging.enable_vector_agent {
Expand Down

0 comments on commit 6008a8f

Please sign in to comment.