Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable USER_CONF_ROOT path #489

Open
ScottWales opened this issue Sep 1, 2023 · 4 comments · May be fixed by #496
Open

Configurable USER_CONF_ROOT path #489

ScottWales opened this issue Sep 1, 2023 · 4 comments · May be fixed by #496

Comments

@ScottWales
Copy link

Problem

The USER_CONF_ROOT path is used in a variety of places for storing logs, secrets and the Jupyter database. While most uses are configurable in jupyter_config.py, the output path of RotatingUISFileHandler is not. We'd like to place this log in a different location with append-only permissions.

Proposed Solution

  • Allow USER_CONF_ROOT to be configured with an environment variable, e.g. $CYLC_CONF_PATH in the same way as cylc-flow.

and/or

  • Add a new configuration item e.g. c.CylcUIServer.server_log_path that sets an output path for RotatingUISFileHandler (defaulting to USER_CONF_ROOT/log as it currently does).

I can see a complication that RotatingUISFileHandler is initialised very early in the startup, potentially before the configuration is loaded.

@hjoliver
Copy link
Member

hjoliver commented Sep 1, 2023

Sounds reasonable.

@ScottWales ScottWales linked a pull request Sep 8, 2023 that will close this issue
8 tasks
@oliver-sanders
Copy link
Member

Note, the logging that Jupyter Server / Cylc UI Server uses is already configurable.

Here's the default configuration:

c.CylcUIServer.logging_config = {
'version': 1,
'handlers': {
'file': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'INFO',
'filename': str(USER_CONF_ROOT / 'log' / 'log'),
'mode': 'a',
'backupCount': 5,
'maxBytes': 10485760,
'formatter': 'file_fmt',
},
},
'loggers': {
'CylcUIServer': {
'level': 'INFO',
'handlers': ['console', 'file'],
},
'cylc': {
'level': 'INFO',
'handlers': ['console', 'file'],
},
},
'formatters': {
'file_fmt': {
'format': '%(asctime)s %(levelname)-8s %(message)s',
'datefmt': '%Y-%m-%dT%H:%M:%S',
}
},
}

E.G. swap out the filename for something like Path('~/my-log-dir').expanduser() and put that in the site-config to point all logging somewhere different.

@oliver-sanders
Copy link
Member

oliver-sanders commented Sep 8, 2023

We'd like to place this log in a different location with append-only permissions.

Unix file permissions are read/write/execute so I think append-only permissions could only be implemented at the filesystem level using something funky.

Note that Cylc is currently configured to open the log file using Python's append mode:

@oliver-sanders
Copy link
Member

Note, you can do some advanced things like chown using Python's logging config which is what's used to interpret the logging_config configuration e.g:

https://docs.python.org/3/howto/logging-cookbook.html#customizing-handlers-with-dictconfig

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 a pull request may close this issue.

3 participants