Skip to content

Commit

Permalink
Remove HasValidBundle condition (#990)
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
  • Loading branch information
m1kola committed Jun 28, 2024
1 parent cab41aa commit 97fb589
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 34 deletions.
14 changes: 5 additions & 9 deletions api/v1alpha1/clusterextension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ type CRDUpgradeSafetyPreflightConfig struct {

const (
// TODO(user): add more Types, here and into init()
TypeInstalled = "Installed"
TypeResolved = "Resolved"
TypeHasValidBundle = "HasValidBundle"
TypeInstalled = "Installed"
TypeResolved = "Resolved"

// TypeDeprecated is a rollup condition that is present when
// any of the deprecated conditions are present.
Expand All @@ -121,10 +120,9 @@ const (
ReasonInstallationSucceeded = "InstallationSucceeded"
ReasonResolutionFailed = "ResolutionFailed"

ReasonSuccess = "Success"
ReasonDeprecated = "Deprecated"
ReasonUpgradeFailed = "UpgradeFailed"
ReasonHasValidBundleUnknown = "HasValidBundleUnknown"
ReasonSuccess = "Success"
ReasonDeprecated = "Deprecated"
ReasonUpgradeFailed = "UpgradeFailed"

ReasonUnpackPending = "UnpackPending"
ReasonUnpackSuccess = "UnpackSuccess"
Expand All @@ -139,7 +137,6 @@ func init() {
conditionsets.ConditionTypes = append(conditionsets.ConditionTypes,
TypeInstalled,
TypeResolved,
TypeHasValidBundle,
TypeDeprecated,
TypePackageDeprecated,
TypeChannelDeprecated,
Expand All @@ -157,7 +154,6 @@ func init() {
ReasonBundleLoadFailed,
ReasonErrorGettingClient,
ReasonInstallationStatusUnknown,
ReasonHasValidBundleUnknown,
ReasonUnpackPending,
ReasonUnpackSuccess,
ReasonUnpackFailed,
Expand Down
3 changes: 1 addition & 2 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
switch unpackResult.State {
case rukpaksource.StatePending:
setStatusUnpackPending(ext, unpackResult.Message)
setHasValidBundleUnknown(ext, "unpack pending")
setInstalledStatusConditionUnknown(ext, "installation has not been attempted as unpack is pending")

return ctrl.Result{}, nil
Expand All @@ -294,7 +293,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp

bundleFS, err := r.Storage.Load(ctx, ext)
if err != nil {
setHasValidBundleFailed(ext, err.Error())
setInstalledStatusConditionFailed(ext, err.Error())
return ctrl.Result{}, err
}

Expand Down
22 changes: 0 additions & 22 deletions internal/controllers/common_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,6 @@ func setInstalledStatusConditionUnknown(ext *ocv1alpha1.ClusterExtension, messag
})
}

// setHasValidBundleUnknown sets the valid bundle condition to unknown.
func setHasValidBundleUnknown(ext *ocv1alpha1.ClusterExtension, message string) {
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
Type: ocv1alpha1.TypeHasValidBundle,
Status: metav1.ConditionUnknown,
Reason: ocv1alpha1.ReasonHasValidBundleUnknown,
Message: message,
ObservedGeneration: ext.GetGeneration(),
})
}

// setHasValidBundleFalse sets the ivalid bundle condition to false
func setHasValidBundleFailed(ext *ocv1alpha1.ClusterExtension, message string) {
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
Type: ocv1alpha1.TypeHasValidBundle,
Status: metav1.ConditionFalse,
Reason: ocv1alpha1.ReasonBundleLoadFailed,
Message: message,
ObservedGeneration: ext.GetGeneration(),
})
}

// setResolvedStatusConditionFailed sets the resolved status condition to failed.
func setResolvedStatusConditionFailed(ext *ocv1alpha1.ClusterExtension, message string) {
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/cluster_extension_install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"

ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
"github.com/operator-framework/operator-controller/internal/conditionsets"
)

const (
Expand Down Expand Up @@ -82,7 +83,7 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
t.Log("By eventually reporting a successful resolution and bundle path")
require.EventuallyWithT(t, func(ct *assert.CollectT) {
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
assert.Len(ct, clusterExtension.Status.Conditions, 8)
assert.Len(ct, clusterExtension.Status.Conditions, len(conditionsets.ConditionTypes))
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved)
if !assert.NotNil(ct, cond) {
return
Expand Down

0 comments on commit 97fb589

Please sign in to comment.