|
1 | 1 | use std::{collections::BTreeSet, ops::Deref, str::FromStr}; |
2 | 2 |
|
| 3 | +use indoc::formatdoc; |
3 | 4 | use serde::{Deserialize, Serialize}; |
4 | 5 | use snafu::{ResultExt, Snafu}; |
5 | 6 | use stackable_operator::{ |
@@ -38,6 +39,7 @@ use stackable_operator::{ |
38 | 39 | status::condition::{ClusterCondition, HasStatusCondition}, |
39 | 40 | utils::{COMMON_BASH_TRAP_FUNCTIONS, crds::raw_object_list_schema}, |
40 | 41 | v2::{ |
| 42 | + builder::pod::container::EnvVarName, |
41 | 43 | config_overrides::KeyValueConfigOverrides, |
42 | 44 | flask_config_writer::{FlaskAppConfigOptions, PythonType}, |
43 | 45 | product_logging::framework::STACKABLE_LOG_DIR, |
@@ -84,6 +86,14 @@ pub const CONFIG_PATH: &str = "/stackable/app/config"; |
84 | 86 | pub const LOG_CONFIG_DIR: &str = "/stackable/app/log_config"; |
85 | 87 | pub const AIRFLOW_HOME: &str = "/stackable/airflow"; |
86 | 88 |
|
| 89 | +// The `stackable-telemetry` variables which configure the file logs of the `containerdebug` |
| 90 | +// process. They are set on the Airflow container in `env_vars`, and the start command below |
| 91 | +// references the directory as a shell variable, so that an `envOverrides` entry for it takes |
| 92 | +// effect in both places. |
| 93 | +constant!(pub FILE_LOG_DIRECTORY: EnvVarName = "FILE_LOG_DIRECTORY"); |
| 94 | +constant!(pub FILE_LOG_MAX_FILES: EnvVarName = "FILE_LOG_MAX_FILES"); |
| 95 | +constant!(pub FILE_LOG_ROTATION_PERIOD: EnvVarName = "FILE_LOG_ROTATION_PERIOD"); |
| 96 | + |
87 | 97 | constant!(pub TEMPLATE_VOLUME_NAME: VolumeName = "airflow-executor-pod-template"); |
88 | 98 | pub const TEMPLATE_LOCATION: &str = "/templates"; |
89 | 99 | pub const TEMPLATE_NAME: &str = "airflow_executor_pod_template.yaml"; |
@@ -779,9 +789,11 @@ fn container_debug_command() -> String { |
779 | 789 | // The log directory is created here, because `FILE_LOG_MAX_FILES` makes the telemetry library |
780 | 790 | // prune old log files before it creates the first one, which complains about the directory not |
781 | 791 | // existing yet. |
782 | | - format!( |
783 | | - "mkdir --parents \"$FILE_LOG_DIRECTORY\"\n\ |
784 | | - containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &" |
| 792 | + formatdoc!( |
| 793 | + r#" |
| 794 | + mkdir --parents "${file_log_directory}" || true |
| 795 | + containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &"#, |
| 796 | + file_log_directory = FILE_LOG_DIRECTORY.as_ref(), |
785 | 797 | ) |
786 | 798 | } |
787 | 799 |
|
@@ -1035,6 +1047,9 @@ mod tests { |
1035 | 1047 | let _ = *WORKER_ROLE_NAME; |
1036 | 1048 | let _ = *DAG_PROCESSOR_ROLE_NAME; |
1037 | 1049 | let _ = *TRIGGERER_ROLE_NAME; |
| 1050 | + let _ = *FILE_LOG_DIRECTORY; |
| 1051 | + let _ = *FILE_LOG_MAX_FILES; |
| 1052 | + let _ = *FILE_LOG_ROTATION_PERIOD; |
1038 | 1053 | let _ = *TEMPLATE_VOLUME_NAME; |
1039 | 1054 | let _ = *LISTENER_PVC_NAME; |
1040 | 1055 | let _ = *METRICS_CONTAINER_NAME; |
|
0 commit comments