mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 18:09:57 +00:00
fix no requeue when return requeueError (#1041)
Some checks failed
Post / coverage (push) Failing after 35m11s
Post / images (amd64) (push) Failing after 8m52s
Post / images (arm64) (push) Failing after 8m9s
Post / image manifest (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Failing after 1m48s
Close stale issues and PRs / stale (push) Successful in 1m4s
Some checks failed
Post / coverage (push) Failing after 35m11s
Post / images (amd64) (push) Failing after 8m52s
Post / images (arm64) (push) Failing after 8m9s
Post / image manifest (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Failing after 1m48s
Close stale issues and PRs / stale (push) Successful in 1m4s
Signed-off-by: Zhiwei Yin <zyin@redhat.com>
This commit is contained in:
@@ -2,11 +2,11 @@ package gc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/openshift/library-go/pkg/controller/factory"
|
||||
"github.com/openshift/library-go/pkg/operator/events"
|
||||
"github.com/pkg/errors"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -98,6 +98,10 @@ func (r *GCController) sync(ctx context.Context, controllerContext factory.SyncC
|
||||
|
||||
gcErr := r.gcResourcesController.reconcile(ctx, copyCluster, clusterName)
|
||||
if cluster == nil {
|
||||
if errors.Is(gcErr, requeueError) {
|
||||
controllerContext.Queue().AddAfter(clusterName, requeueError.RequeueTime)
|
||||
return nil
|
||||
}
|
||||
return gcErr
|
||||
}
|
||||
|
||||
@@ -117,6 +121,10 @@ func (r *GCController) sync(ctx context.Context, controllerContext factory.SyncC
|
||||
return err
|
||||
}
|
||||
|
||||
if errors.Is(gcErr, requeueError) {
|
||||
controllerContext.Queue().AddAfter(clusterName, requeueError.RequeueTime)
|
||||
return nil
|
||||
}
|
||||
if gcErr != nil {
|
||||
return gcErr
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package managedcluster
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -11,7 +12,7 @@ import (
|
||||
operatorhelpers "github.com/openshift/library-go/pkg/operator/v1helpers"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@@ -121,8 +122,13 @@ func (c *managedClusterController) sync(ctx context.Context, syncCtx factory.Syn
|
||||
logger := klog.FromContext(ctx)
|
||||
logger.V(4).Info("Reconciling ManagedCluster", "managedClusterName", managedClusterName)
|
||||
managedCluster, err := c.clusterLister.Get(managedClusterName)
|
||||
if errors.IsNotFound(err) {
|
||||
return c.removeClusterRbac(ctx, managedClusterName, true)
|
||||
if apierrors.IsNotFound(err) {
|
||||
err = c.removeClusterRbac(ctx, managedClusterName, true)
|
||||
if errors.Is(err, requeueError) {
|
||||
syncCtx.Queue().AddAfter(managedClusterName, requeueError.RequeueTime)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -137,6 +143,10 @@ func (c *managedClusterController) sync(ctx context.Context, syncCtx factory.Syn
|
||||
|
||||
err = c.removeClusterRbac(ctx, managedClusterName, true)
|
||||
if err != nil {
|
||||
if errors.Is(err, requeueError) {
|
||||
syncCtx.Queue().AddAfter(managedClusterName, requeueError.RequeueTime)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -193,7 +203,12 @@ func (c *managedClusterController) sync(ctx context.Context, syncCtx factory.Syn
|
||||
}
|
||||
|
||||
// Remove the cluster role binding files for registration-agent and work-agent.
|
||||
return c.removeClusterRbac(ctx, managedClusterName, managedCluster.Spec.HubAcceptsClient)
|
||||
err = c.removeClusterRbac(ctx, managedClusterName, managedCluster.Spec.HubAcceptsClient)
|
||||
if errors.Is(err, requeueError) {
|
||||
syncCtx.Queue().AddAfter(managedClusterName, requeueError.RequeueTime)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO consider to add the managedcluster-namespace.yaml back to staticFiles,
|
||||
@@ -306,7 +321,7 @@ func (c *managedClusterController) removeClusterRbac(ctx context.Context, cluste
|
||||
}
|
||||
|
||||
works, err := c.manifestWorkLister.ManifestWorks(clusterName).List(labels.Everything())
|
||||
if err != nil && !errors.IsNotFound(err) {
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
errs = append(errs, err)
|
||||
return operatorhelpers.NewMultiLineAggregate(errs)
|
||||
}
|
||||
@@ -320,7 +335,7 @@ func (c *managedClusterController) removeClusterRbac(ctx context.Context, cluste
|
||||
func (c *managedClusterController) removeFinalizerFromWorkRoleBinding(ctx context.Context, clusterName string) error {
|
||||
workRoleBinding, err := c.roleBindingLister.RoleBindings(clusterName).Get(workRoleBindingName(clusterName))
|
||||
switch {
|
||||
case errors.IsNotFound(err):
|
||||
case apierrors.IsNotFound(err):
|
||||
return nil
|
||||
case err != nil:
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user