Skip to content

Commit e045be4

Browse files
JustinKuliopenshift-ci[bot]
authored andcommitted
Ignore synced policies for hosted clusters
Signed-off-by: Justin Kulikauskas <[email protected]> (cherry picked from commit bbe07497d20faf3ac2223fe1606afa5ca345965b)
1 parent ed7f6ca commit e045be4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

controllers/propagator/replicatedpolicy_controller.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@ func (r *ReplicatedPolicyReconciler) Reconcile(ctx context.Context, request ctrl
9797
return reconcile.Result{}, nil
9898
}
9999

100-
// do not handle a replicated policy which does not belong to the current cluster
101100
inClusterNS, err := common.IsInClusterNamespace(r.Client, request.Namespace)
102101
if err != nil {
103102
return reconcile.Result{}, err
104103
}
105104

106105
if !inClusterNS {
106+
// "Hub of hubs" scenario: this cluster is managed by another cluster,
107+
// which has the root policy for the policy being reconciled.
107108
log.V(1).Info("Found a replicated policy in non-cluster namespace, skipping it")
108109

109110
return reconcile.Result{}, nil
@@ -160,6 +161,19 @@ func (r *ReplicatedPolicyReconciler) Reconcile(ctx context.Context, request ctrl
160161
// an empty decision means the policy should not be replicated
161162
if decision.Cluster.ClusterName == "" {
162163
if replicatedExists {
164+
inClusterNS, err := common.IsInClusterNamespace(r.Client, request.Namespace)
165+
if err != nil {
166+
return reconcile.Result{}, err
167+
}
168+
169+
if !inClusterNS {
170+
// "Hosted mode" scenario: this cluster is hosting another cluster, which is syncing
171+
// this policy to a cluster namespace that this propagator doesn't know about.
172+
log.V(1).Info("Found a possible replicated policy for a hosted cluster, skipping it")
173+
174+
return reconcile.Result{}, nil
175+
}
176+
163177
if err := r.cleanUpReplicated(ctx, replicatedPolicy); err != nil {
164178
if !k8serrors.IsNotFound(err) {
165179
log.Error(err, "Failed to remove the replicated policy for this managed cluster, requeueing")

0 commit comments

Comments
 (0)