I am using Airflow to periodically run a query on an Oracle server. The connection string is defined in an Airflow variable called password_oracle_connections, so that it remains secret.
The DAG instantiates a Docker image, for which it defines an OS variable called PASSWORD_CX:
dag_task_name = "Oracle_Monitoring"
with DAG(dag_task_name, default_args=default_args, catchup=False) as dag:
task1 = DockerOperator(
task_id=dag_task_name,
image="repo.cargo.fr:8444/ass/airflow-oracle-monitoring:v0.1.0",
command='/bin/bash -c 'printenv;
echo "=== My context ===";
ls -l /app;
echo "==================";
python /app/oracle_monitor.py'',
auto_remove=True,
xcom_all=True,
tty=True,
force_pull=True,
environment={
"TEST": "test",
"PASSWORD_CX": "{{ var.value.password_oracle_connections}}"
}
)
It works as expected, but the OS variable remains visible in the DAG’s log!
[2024-05-31, 14:40:46 UTC] {docker.py:373} INFO - PASSWORD_CX=[{
"context": "DEV-INTS1: LCDE",
"user": "MONITOR_ADMIN_USER",
"password": "vY2J2XEgE$3NX*$#Fb7T!7as",
"server": "INTS1_SRV"
}]
How can I hide this, or change the log level for this DAG only?