Skip to content

HDDS-14805. Escape log4j variables in docker-compose templates#9930

Open
navinko wants to merge 2 commits intoapache:masterfrom
navinko:HDDS-14805
Open

HDDS-14805. Escape log4j variables in docker-compose templates#9930
navinko wants to merge 2 commits intoapache:masterfrom
navinko:HDDS-14805

Conversation

@navinko
Copy link
Contributor

@navinko navinko commented Mar 15, 2026

What changes were proposed in this pull request?

This PR fixes an issue in the Ozone docker-compose templates where ${} patterns inside Log4j configuration were interpreted by docker-compose as environment variable substitutions.This change escapes the Log4j variable expressions in the docker-compose templates so that they are preserved and correctly interpreted by Log4j at runtime instead of being processed by docker-compose.
As per docker doc: https://github.com/docker/docs/blob/3c79e7c2ac175507a245f55602549e8cecc1b6e1/content/reference/compose-file/interpolation.md?plain=1#L40

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-14805

How was this patch tested?

CI : https://github.com/navinko/ozone/actions/runs/23208249818

#Before fix (Broken)

% docker-compose up -d
WARN[0000] The "hostName" variable is not set. Defaulting to a blank string.
Invalid template: "${sys:hadoop.log.dir}/om-audit-${hostName}.log"

#After fix (Working)

% docker-compose up -d
[+] Running 6/6
✔ Network ozone-om-ha_default Created 0.0s
✔ Container ozone-om-ha-scm-1 Started 0.6s
✔ Container ozone-om-ha-om2-1 Started 0.6s
✔ Container ozone-om-ha-om3-1 Started 0.6s
✔ Container ozone-om-ha-datanode-1 Started 0.6s
✔ Container ozone-om-ha-om1-1 Started 0.5s
% docker-compose exec -it om1 bash
bash-5.1$ cd /var/log/hadoop
bash-5.1$ ls -lart
total 12
drwxr-xr-x 1 root root 4096 Feb 6 11:50 ..
-rw-r--r-- 1 hadoop hadoop 0 Mar 15 16:36 om-audit-96bc0c52e252.log
-rw-r--r-- 1 hadoop hadoop 0 Mar 15 16:36 om-sys-audit-96bc0c52e252.log
drwxrwxrwt 1 root root 4096 Mar 15 16:36 .
bash-5.1$

@priyeshkaratha
Copy link
Contributor

priyeshkaratha commented Mar 17, 2026

@navinko Thanks for the patch. I can see similar entries at hadoop-ozone/fault-injection-test/network-tests/src/test/compose/docker-config also. Can you check whether this change require here too?

@navinko
Copy link
Contributor Author

navinko commented Mar 17, 2026

Can you check whether this change require here too?

@navinko Thanks for the patch. I can see similar entries at hadoop-ozone/fault-injection-test/network-tests/src/test/compose/docker-config also. Can you check whether this change require here too?

Thanks @priyeshkaratha for reviewing . I left that intensionally as was not able to test it .
I tested it finally and yes this is also a candidate. Updated the changes .

Copy link
Contributor

@priyeshkaratha priyeshkaratha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @navinko for updating the patch. Changes LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants