mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-07-08 02:32:21 +02:00
chore: add review comments and clean up whitespace
Document the upgrade gap for pre-existing Roles without the ClusterLabelName label, the single-owner assumption in SetControllerReference, and the race window between the Pre hook and the ObjectStore controller. Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
This commit is contained in:
parent
61350c794c
commit
aae694f539
@ -42,6 +42,13 @@ import (
|
|||||||
// This function is called from the Pre hook (gRPC). It creates the
|
// This function is called from the Pre hook (gRPC). It creates the
|
||||||
// Role if it does not exist, then patches rules and labels to match
|
// Role if it does not exist, then patches rules and labels to match
|
||||||
// the desired state.
|
// the desired state.
|
||||||
|
//
|
||||||
|
// Note: the ObjectStore controller (EnsureRoleRules) can patch the
|
||||||
|
// same Role concurrently. Both paths use RetryOnConflict but compute
|
||||||
|
// desired rules from their own view of ObjectStores. If the Pre hook
|
||||||
|
// reads stale ObjectStore data from the informer cache, it may
|
||||||
|
// briefly revert a fresher update. This is self-healing: the next
|
||||||
|
// ObjectStore reconcile restores the correct state.
|
||||||
func EnsureRole(
|
func EnsureRole(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
c client.Client,
|
c client.Client,
|
||||||
|
|||||||
@ -33,6 +33,11 @@ import (
|
|||||||
// the operator does not know the CNPG API group at compile time
|
// the operator does not know the CNPG API group at compile time
|
||||||
// (it may be customized), while the Cluster object decoded from
|
// (it may be customized), while the Cluster object decoded from
|
||||||
// the gRPC request carries the correct GVK in its TypeMeta.
|
// the gRPC request carries the correct GVK in its TypeMeta.
|
||||||
|
//
|
||||||
|
// This function replaces all existing owner references rather than
|
||||||
|
// merging, so it assumes the controlled object has a single owner.
|
||||||
|
// This holds for plugin-managed Roles and RoleBindings, which are
|
||||||
|
// exclusively owned by one Cluster.
|
||||||
func SetControllerReference(owner, controlled metav1.Object) error {
|
func SetControllerReference(owner, controlled metav1.Object) error {
|
||||||
ro, ok := owner.(runtime.Object)
|
ro, ok := owner.(runtime.Object)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@ -32,7 +32,6 @@ import (
|
|||||||
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/common"
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// Start starts the sidecar informers and CNPG-i server
|
// Start starts the sidecar informers and CNPG-i server
|
||||||
func Start(ctx context.Context) error {
|
func Start(ctx context.Context) error {
|
||||||
setupLog := log.FromContext(ctx)
|
setupLog := log.FromContext(ctx)
|
||||||
|
|||||||
@ -68,6 +68,10 @@ func (r *ObjectStoreReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
|||||||
|
|
||||||
contextLogger.Info("ObjectStore reconciliation start")
|
contextLogger.Info("ObjectStore reconciliation start")
|
||||||
|
|
||||||
|
// NOTE: Roles created before the introduction of ClusterLabelName
|
||||||
|
// are not discovered here. The Pre hook patches the label on every
|
||||||
|
// Cluster reconciliation, so unlabeled Roles are picked up after
|
||||||
|
// the next Cluster reconcile cycle.
|
||||||
var roleList rbacv1.RoleList
|
var roleList rbacv1.RoleList
|
||||||
if err := r.List(ctx, &roleList,
|
if err := r.List(ctx, &roleList,
|
||||||
client.InNamespace(req.Namespace),
|
client.InNamespace(req.Namespace),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user