From da48d55877613953b175049408eb075fa182ee97 Mon Sep 17 00:00:00 2001 From: Rashmi Gottipati Date: Wed, 26 Jun 2024 15:01:40 -0400 Subject: [PATCH] Address review comments Signed-off-by: Rashmi Gottipati --- .../clusterextension_controller.go | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index 4b8d9ec20..84c65e09d 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -63,8 +63,8 @@ import ( "github.com/operator-framework/operator-registry/alpha/declcfg" "github.com/operator-framework/operator-registry/alpha/property" rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" - "github.com/operator-framework/rukpak/pkg/features" registryv1handler "github.com/operator-framework/rukpak/pkg/handler" + crdupgradesafety "github.com/operator-framework/rukpak/pkg/preflights/crdupgradesafety" rukpaksource "github.com/operator-framework/rukpak/pkg/source" "github.com/operator-framework/rukpak/pkg/storage" "github.com/operator-framework/rukpak/pkg/util" @@ -330,17 +330,22 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp } for _, preflight := range r.Preflights { + if _, ok := preflight.(*crdupgradesafety.Preflight); ok && ext.Spec.Preflight.CRDUpgradeSafety.Disabled { + // Skip this preflight check because it is of type *crdupgradesafety.Preflight and the CRD Upgrade Safety + // preflight check has been disabled + continue + } switch state { case stateNeedsInstall: err := preflight.Install(ctx, desiredRel) if err != nil { - setInstalledAndHealthyFalse(ext, rukpakv1alpha2.ReasonInstallFailed, err.Error()) + setInstalledStatusConditionFailed(ext, fmt.Sprintf("%s:%v", ocv1alpha1.ReasonInstallationFailed, err)) return ctrl.Result{}, err } case stateNeedsUpgrade: err := preflight.Upgrade(ctx, desiredRel) if err != nil { - setInstalledAndHealthyFalse(ext, rukpakv1alpha2.ReasonInstallFailed, err.Error()) + setInstalledStatusConditionFailed(ext, fmt.Sprintf("%s:%v", ocv1alpha1.ReasonInstallationFailed, err)) return ctrl.Result{}, err } } @@ -782,23 +787,3 @@ func (r *ClusterExtensionReconciler) validateBundle(bundle *catalogmetadata.Bund return nil } - -// setInstalledAndHealthyFalse sets the Installed and if the feature gate is enabled, the Healthy conditions to False, -// and allows to set the Installed condition reason and message. -func setInstalledAndHealthyFalse(ext *ocv1alpha1.ClusterExtension, installedConditionReason, installedConditionMessage string) { - apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha2.TypeInstalled, - Status: metav1.ConditionFalse, - Reason: installedConditionReason, - Message: installedConditionMessage, - }) - - if features.RukpakFeatureGate.Enabled(features.BundleDeploymentHealth) { - apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: rukpakv1alpha2.TypeHealthy, - Status: metav1.ConditionFalse, - Reason: rukpakv1alpha2.ReasonInstallationStatusFalse, - Message: "Installed condition is false", - }) - } -}