From a6760d37ec59410154daf732331be7061d5a3279 Mon Sep 17 00:00:00 2001 From: Naadir Jeewa Date: Wed, 19 Oct 2022 12:24:01 +0100 Subject: [PATCH] cluster_bootstrap: Short requeue if CRD not found on remote cluster On clusters where kapp is taking a long time to get installed (slow registries etc...), cluster_bootstrap controller may end up in exponential backoff because some CRDs do not exist yet on the remote cluster. This change checks for this particular error, and requeues the cluster for retry after 10s. Signed-off-by: Naadir Jeewa --- addons/controllers/clusterbootstrap_controller.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/controllers/clusterbootstrap_controller.go b/addons/controllers/clusterbootstrap_controller.go index 89220f4534..2aa970df66 100644 --- a/addons/controllers/clusterbootstrap_controller.go +++ b/addons/controllers/clusterbootstrap_controller.go @@ -14,6 +14,7 @@ import ( corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" 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/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -251,6 +252,11 @@ func (r *ClusterBootstrapReconciler) createOrPatchResourcesForCorePackages(clust // packages, we return error and let the reconciler retry again. log.Error(err, fmt.Sprintf("unable to create or patch all the required resources for %s on cluster: %s/%s", corePackage.RefName, cluster.Namespace, cluster.Name)) + if meta.IsNoMatchError(err) { + // If the remote cluster does not have the required CRDs, we will requeue the request to try again in 10s. + log.Error(err, "reconciler error - required CRDs are not yet installed, requeing request in 10s") + return ctrl.Result{RequeueAfter: constants.RequeueAfterDuration}, nil + } return ctrl.Result{}, err } // set watches on provider objects in core packages if not already set