cloudnative-pg / cloudnative-pg/plugin-barman-cloud

`isWALArchiever` is ignored when multiple Barman Cloud plugins defined

オープン
#934 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
bug
主要言語
Go
スター
191
フォーク
72
平均マージ
1日 16時間
マージ済み PR(30日)
18

説明

## 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:

```yaml
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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

internal/cnpgi/operator/config/config.go、特に NewPlugin と NewFromCluster から始め、issue にある重複名の設定を再現してください。その解決方法を、CNPG の検証および WAL-archiver の選択に関する参照と比較してください。重複エントリの動作が明示的に処理され、適切なテストでカバーされるか、意図した動作として文書化されていれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
go, kubernetes, postgresql
領域
backend, databases
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。