project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Feature] Add configuration options for <install>/config and <install>/logs

Open avsdev-cw opened this issue 2 months ago • 5 comments

Describe the feature

Allow the config (AFIK the only required state persistent data - includes all credentials, clusters, etc) and the logs folders to be configured to custom paths.

Use Case

All our container system logs are stored on volatile storage which is not included in backups (minimal backup deltas). Additionally, our backups of container rootfs are slow moving (weekly or so). Any critical data directories (databases etc) are backed up more frequently (hourly, daily, or whatever).

In order to use the same pattern for pegaprox, the ability to specify where /config and logs should actually be located is required.

Alternatives considered

Disabling the file logs that are generated.

How important is this for you?

Makes pegaprox consistent with many other applications which allow this kind of configuration to be done either by config file or by environment variables. Especially the logs.

Checklist

  • [x] I have searched existing issues and discussions to make sure this hasn't been requested before

avsdev-cw avatar Sep 15 '26 12:09 avsdev-cw

Not possible today — CONFIG_DIR and LOG_DIR are plain relative paths (config, logs) resolved against the working directory, which the unit file sets to /var/lib/pegaprox. Everything else derives from those two constants, so making them env-driven is a small change in one file.

What makes it not just a small change is what moves with it: the encrypted DB, the keystore and all cluster credentials live under config, so it touches the Docker volume declaration, the .deb layout and the update path too. I've put it in front of Nico rather than deciding the shape myself. Noted, no date from me.

Meanwhile two things that work without us changing anything: PEGAPROX_DISABLE_FILE_LOG=1 drops the file logs entirely if that's enough for the logs half, and a bind-mount over /var/lib/pegaprox/config gets you the separate backup cadence you're after.

— MK

mkellermann97 avatar Sep 15 '26 13:09 mkellermann97

Thanks for the tips, I had spotted the PEGAPROX_DISABLE_FILE_LOG option but didn't want to use it as yet as I am still playing around with things and the debug log might be useful.

Also, for my installation (using the provided install script) everything is relative to /opt/PegaProx rather than /var/lib/pegaprox. Looking at the docker install it seems to be /app (I'm not huge on docker so I may be wrong on that...). My guess is that it is all relative to wherever the install is?

avsdev-cw avatar Sep 15 '26 14:09 avsdev-cw

Your guess is right and I quoted the wrong unit file — sorry. There are three roots depending on how you installed:

  • install script → WorkingDirectory=/opt/PegaProx (that's you)
  • packaged/systemd unit → /var/lib/pegaprox
  • Docker → WORKDIR /app

In all three it's the working directory that decides, and config/ and logs/ hang off it relatively, so your read of "relative to wherever the install is" is exactly it. For your box the bind-mount target is /opt/PegaProx/config, not what I wrote earlier.

Which is also a decent argument for the ticket itself: three install methods, three answers, and the only way to find out is to read the unit file. Still Nico's call on the shape.

Marcus

mkellermann97 avatar Sep 15 '26 15:09 mkellermann97

Built, on Testing. Two environment variables, and you can point them at different places:

PEGAPROX_CONFIG_DIR=/srv/state/pegaprox    # database, master key, settings, TLS pair, branding
PEGAPROX_LOG_DIR=/var/log/pegaprox         # the per-cluster log files

Unset or blank keeps today's relative paths, so nothing moves for anyone who does not set them. For you that means the state can sit on the directory you back up hourly while the logs stay on the volatile mount, without touching /opt/PegaProx itself.

Two details that came out of building it:

  • mkdir now passes parents=True for both. A moved path is nested almost by definition (/srv/state/pegaprox/config) and the old single-level mkdir would have failed on the very first start - which would have made this feature look broken on exactly the layout people will use.
  • The config directory keeps its 0700 wherever it lands. It holds the master key and the encrypted database, and that is not something to leave behind when the path becomes explicit.

Everything else in constants.py is derived from these two with os.path.join, so reading the environment before anything is joined onto them is the whole change - but the derived paths are tested too, because deriving before reading the environment is precisely the bug that would have shipped otherwise: a database in the new place and the TLS pair in the old one is worse than not supporting this at all.

You mentioned PEGAPROX_DISABLE_FILE_LOG - you should not need it for this any more. Point PEGAPROX_LOG_DIR at the volatile mount and keep the debug log.

MrMasterbay avatar Sep 28 '26 21:09 MrMasterbay

PEGAPROX_CONFIG_DIR and PEGAPROX_LOG_DIR are now read at startup, so the state and the logs can live in separate places. Leaving them unset keeps the current relative paths. Nested target paths are created on the first start, and the config directory keeps its 0700 permissions wherever it lands. This ships in 1.3.0.

PegaProx runs on donations, https://opencollective.com/pegaprox if you want to chip in.

Marcus

mkellermann97 avatar Oct 07 '26 04:10 mkellermann97