chihsuan opened a new pull request, #10444:
URL: https://github.com/apache/ozone/pull/10444
## What changes were proposed in this pull request?
Running any Ozone CLI command (e.g. `ozone s3`) prints a scary log4j error
when the log directory does not exist and cannot be created by the current
user, e.g. with the debian package where `/opt/ozone` is owned by root:
```
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /opt/ozone/logs/access.log (No such file or
directory)
```
Root cause: HDDS-12805 moved the HTTP request log into the shared
`log4j.properties` with an unconditional
`log4j.logger.http.requests=INFO,HttpAccess`. log4j instantiates the
`HttpAccess` file appender at configuration time for every command, eagerly
opening `${hadoop.log.dir}/access.log`. CLI commands never create the log
directory (only the daemon handlers call `ozone_verify_logdir`), and reload4j's
`FileAppender` fallback `mkdirs()` fails when the parent is not writable. Note
that pre-creating the directory at install time would not be enough either: if
the directory exists but is not writable by the user, the same error is raised
with `(Permission denied)`.
This PR makes the `http.requests` logger destination configurable via the
`ozone.http.request.logger` system property, following the existing
`hadoop.root.logger` pattern:
- `log4j.properties` defines the default `INFO,console`, so commands never
touch `access.log` (the appender is only instantiated when referenced)
- the `ozone` command sets `-Dozone.http.request.logger` from
`OZONE_HTTP_REQUEST_LOGGER` (default `INFO,console`) or
`OZONE_DAEMON_HTTP_REQUEST_LOGGER` (default `INFO,HttpAccess`) for daemons
started with `--daemon`, at the same place `OZONE_ROOT_LOGGER` is switched
Daemon behavior is unchanged: `access.log` is still written as before. The
new environment variables are documented in `ozone-env.sh`.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15419
## How was this patch tested?
Reproduced the exact stack trace from the Jira by running `bin/ozone s3`
from a dist with `OZONE_LOG_DIR` pointing under a non-writable parent
directory. With this change:
- same CLI scenario: error is gone, clean usage output,
`-Dozone.http.request.logger=INFO,console` is passed
- `ozone --daemon start om`: `-Dozone.http.request.logger=INFO,HttpAccess`
is passed and `access.log` is created in `OZONE_LOG_DIR` as before
Added bats tests for the new variable propagation
(`http_request_logger.bats`). `bats.sh`, `rat.sh` and `author.sh` pass locally;
`shellcheck` output on `ozone-functions.sh` is unchanged compared to master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]