plugin-barman-cloud icon indicating copy to clipboard operation
plugin-barman-cloud copied to clipboard

[Bug]: instanceSidecarConfiguration.env can't override env inherited from the postgres container

Open AdzerKI opened this issue 2 weeks ago • 0 comments

An env var set in instanceSidecarConfiguration.env is silently dropped when the postgres container already defines it, so TMPDIR, PGHOST and the other variables CNPG sets on the instance can't be changed for the sidecar.

reconcilePodSpec copies the main container env first and then appends the defaults and config.env only for names not already present, so the inherited value always wins.

Where it hurts: barman-cloud-backup stages every upload part in TMPDIR, which the sidecar inherits as /controller/tmp, the disk-backed scratch-data emptyDir. With the default max-archive-size the parts are ~20 MiB, and with data.jobs: 2 up to five of them are in flight. The sidecar memory cgroup (1Gi here) has a low dirty threshold, so most of the base backup goes through the node disk: on a 36 GB database that's about 10 GB of writes per nightly backup, just for temporary files that get deleted right after upload. Pointing TMPDIR at /dev/shm, which the sidecar already mounts, would avoid it, but the setting is ignored.

To reproduce: add

instanceSidecarConfiguration:
  env:
    - name: TMPDIR
      value: /dev/shm

to an ObjectStore, restart the instance and look at the plugin-barman-cloud container env: TMPDIR is still /controller/tmp.

I'd expect the explicitly configured env to take precedence over the inherited one. I'll open a PR that merges config.env before the main container envs.

AdzerKI avatar Nov 19 '26 08:11 AdzerKI