plugin-barman-cloud/internal/cnpgi
Armando Ruocco fe445b154f fix(rbac): reconcile Role when ObjectStore spec changes
When an ObjectStore's credentials change (e.g., secret rename), the
RBAC Role granting the Cluster's ServiceAccount access to those secrets
was not updated because nothing triggered a Cluster reconciliation.

Implement the ObjectStore controller's Reconcile to detect referencing
Clusters and update their Roles directly. Extract ensureRole into a
shared rbac.EnsureRole function used by both the Pre hook and the
ObjectStore controller.

Handle concurrent modifications between the Pre hook and ObjectStore
controller gracefully: AlreadyExists on Create and Conflict on Patch
are retried once to avoid propagating transient errors as gRPC failures
to CNPG.

Replace the custom setOwnerReference helper (ownership.go) with
controllerutil.SetControllerReference for both Role and RoleBinding.
The old helper read the GVK from the object's metadata and replaced
all owner references unconditionally. The new function reads the GVK
from the scheme and appends to existing owner references, refusing to
overwrite if another controller already owns the object. Both produce
identical results for our use case since the Role is always freshly
built. The GVK is now resolved from the scheme configured via
CUSTOM_CNPG_GROUP/CUSTOM_CNPG_VERSION, which must match the actual
CNPG API group (same requirement as the instance sidecar).

Add dynamic CNPG scheme registration (internal/scheme) to the operator,
instance, and restore managers, replacing hardcoded cnpgv1.AddToScheme
calls. Add RBAC permission for the plugin to list/watch Clusters.

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
2026-04-13 13:22:09 +02:00
..
common fix(restore): use custom CNPG group and version for scheme registration (#847) 2026-04-13 13:20:38 +02:00
instance fix(restore): use custom CNPG group and version for scheme registration (#847) 2026-04-13 13:20:38 +02:00
metadata chore(main): release 0.11.0 (#717) 2026-01-30 16:32:12 +01:00
operator fix(rbac): reconcile Role when ObjectStore spec changes 2026-04-13 13:22:09 +02:00
restore fix(rbac): reconcile Role when ObjectStore spec changes 2026-04-13 13:22:09 +02:00