Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
  • Loading branch information
rashmigottipati committed Jun 27, 2024
1 parent 86634d8 commit da48d55
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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",
})
}
}

0 comments on commit da48d55

Please sign in to comment.