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

`isWALArchiever` is ignored when multiple Barman Cloud plugins defined

Open elythh opened this issue 6 months ago • 1 comments

Summary

When defining multiple entries with the same plugin name (barman-cloud.cloudnative-pg.io) in Cluster.spec.plugins, WAL archiving appears to use the parameters of the last matching entry.

In practice, isWALArchiver can look ignored because WALs are pushed using barmanObjectName from the last plugin entry.

Environment

  • CloudNativePG: 1.29.1
  • plugin-barman-cloud: 0.12.0
  • Kubernetes: Kind (local)

Minimal reproduction

Create two object stores:

  • store-a (intended WAL target)
  • store-b (intended backup-only target)

Then use a Cluster with duplicate plugin entries:

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: pg
spec:
  instances: 1
  imageName: ghcr.io/cloudnative-pg/postgresql:16
  storage:
    size: 1Gi
  plugins:
    - name: barman-cloud.cloudnative-pg.io
      isWALArchiver: true
      parameters:
        barmanObjectName: store-a
    - name: barman-cloud.cloudnative-pg.io
      parameters:
        barmanObjectName: store-b

Generate write traffic and inspect object stores.

Expected behavior

WALs should go to store-a because that entry has isWALArchiver: true.

Actual behavior

WALs are pushed to store-b (the last plugin entry in spec.plugins).

Why this seems to happen

From source review:

  1. CNPG validates "at most one WAL archiver" but does not reject duplicate plugin names.
  2. CNPG selects WAL archiver by plugin name.
  3. plugin-barman-cloud config extraction overwrites parameters on each matching plugin name while iterating, so the last matching entry wins.

Relevant source references

  • CNPG webhook validation (at most one WAL archiver):
    • internal/webhook/v1/cluster_webhook.go (validatePluginConfiguration) [1]
  • CNPG WAL archiver plugin name selection:
    • api/v1/cluster_funcs.go (GetEnabledWALArchivePluginName) [2]
  • plugin-barman-cloud parameter resolution (last match wins):
    • internal/cnpgi/operator/config/config.go (NewPlugin, NewFromCluster) [3]

Conclusion / Questions for maintainers

Could you please confirm whether this is the intended behavior when multiple spec.plugins entries share the same plugin name?

If this behavior is intentional:

  • Is it documented somewhere (especially the effective "last matching entry wins" parameter resolution)?

If this behavior is not intentional:

  • Are there plans to fix it (for example by rejecting duplicate plugin names in validation or by making plugin resolution deterministic and explicit)?

Thanks for your time and for maintaining these projects.

[1] https://github.com/cloudnative-pg/cloudnative-pg/blob/758532a6f4bc148f7f73a769e3abbfe3ffbc710c/internal/webhook/v1/cluster_webhook.go#L2788 [2] https://github.com/cloudnative-pg/cloudnative-pg/blob/758532a6f4bc148f7f73a769e3abbfe3ffbc710c/api/v1/cluster_funcs.go#L1547 [3] https://github.com/cloudnative-pg/plugin-barman-cloud/blob/0bb78879ce8202addf1f0d3bbfbf4485f81a1290/internal/cnpgi/operator/config/config.go#L282

elythh avatar Jun 02 '26 09:06 elythh

Hi @elythh! I'm Dosu and I'm helping the CloudNativePG team.

Your analysis is accurate. This is not intentional behavior — it stems from an inconsistency between how CloudNativePG and plugin-barman-cloud handle duplicate plugin names, combined with a known issue where isWALArchiver is largely ignored during actual WAL archiving.

Here's what's happening:

  1. No validation rejects duplicate plugin names. The webhook validation in validatePluginConfiguration only checks that at most one WAL archiver plugin is enabled — it does not check for duplicate names in spec.plugins. [1]

  2. WAL archiver selection uses "first match wins" — GetEnabledWALArchivePluginName returns the first enabled plugin with isWALArchiver: true. [2]

  3. Parameter resolution in barman-cloud uses "last match wins" — NewPlugin iterates all entries and overwrites parameters on each match without breaking, so the last entry's barmanObjectName is used. [3]

  4. isWALArchiver is known to be ignored at archiving time. The archiveWALViaPlugins function invokes all plugins with the WAL_ARCHIVE capability, regardless of the isWALArchiver flag. This is tracked in issue #606 and was also reported in issue #797. [4]

Per maintainer feedback, isWALArchiver is intended as a "designation mechanism" (indicating which plugin is responsible) rather than a control mechanism (enabling/disabling archiving). [5]

So in your case, the combination of:

  • No deduplication validation
  • "Last match wins" parameter resolution
  • isWALArchiver being ignored during actual archiving

…causes WALs to be pushed to store-b instead of store-a.

The recommended workaround is to avoid defining multiple spec.plugins entries with the same plugin name. Use a single entry with isWALArchiver: true pointing to the object store where you want both backups and WALs. If you need a separate backup-only target, that use case isn't currently supported with a single plugin name.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about plugin-barman-cloud Share Dosu with your team

dosubot[bot] avatar Jun 02 '26 09:06 dosubot[bot]