diff --git a/api/v1alpha1/clusterextension_types.go b/api/v1alpha1/clusterextension_types.go index cdb7a4afd..829cb5008 100644 --- a/api/v1alpha1/clusterextension_types.go +++ b/api/v1alpha1/clusterextension_types.go @@ -422,7 +422,6 @@ const ( TypePackageDeprecated = "PackageDeprecated" TypeChannelDeprecated = "ChannelDeprecated" TypeBundleDeprecated = "BundleDeprecated" - TypeUnpacked = "Unpacked" ReasonSuccess = "Succeeded" ReasonDeprecated = "Deprecated" @@ -446,7 +445,6 @@ func init() { TypePackageDeprecated, TypeChannelDeprecated, TypeBundleDeprecated, - TypeUnpacked, TypeProgressing, ) // TODO(user): add Reasons from above diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index 0e7180d1d..cdbe1ade2 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -267,7 +267,6 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp l.V(1).Info("unpacking resolved bundle") unpackResult, err := r.Unpacker.Unpack(ctx, bundleSource) if err != nil { - setStatusUnpackFailed(ext, err.Error()) // Wrap the error passed to this with the resolution information until we have successfully // installed since we intend for the progressing condition to replace the resolved condition // and will be removing the .status.resolution field from the ClusterExtension status API @@ -275,10 +274,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp return ctrl.Result{}, err } - switch unpackResult.State { - case rukpaksource.StateUnpacked: - setStatusUnpacked(ext, unpackResult.Message) - default: + if unpackResult.State != rukpaksource.StateUnpacked { panic(fmt.Sprintf("unexpected unpack state %q", unpackResult.State)) } diff --git a/internal/controllers/clusterextension_controller_test.go b/internal/controllers/clusterextension_controller_test.go index e3f613bf0..d9603fab0 100644 --- a/internal/controllers/clusterextension_controller_test.go +++ b/internal/controllers/clusterextension_controller_test.go @@ -167,12 +167,6 @@ func TestClusterExtensionResolutionSuccessfulUnpackFails(t *testing.T) { require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) - t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) - require.NotNil(t, unpackedCond) - require.Equal(t, metav1.ConditionFalse, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonFailed, unpackedCond.Reason) - progressingCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeProgressing) require.NotNil(t, progressingCond) require.Equal(t, metav1.ConditionTrue, progressingCond.Status) @@ -233,9 +227,12 @@ func TestClusterExtensionUnpackUnexpectedState(t *testing.T) { Image: "quay.io/operatorhubio/prometheus@fake1.0.0", }, &v, nil, nil }) + require.Panics(t, func() { _, _ = reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey}) }, "reconciliation should panic on unknown unpack state") + + require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) } func TestClusterExtensionResolutionAndUnpackSuccessfulApplierFails(t *testing.T) { @@ -312,12 +309,6 @@ func TestClusterExtensionResolutionAndUnpackSuccessfulApplierFails(t *testing.T) require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) - t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) - require.NotNil(t, unpackedCond) - require.Equal(t, metav1.ConditionTrue, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason) - t.Log("By checking the expected installed conditions") installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) require.NotNil(t, installedCond) @@ -410,12 +401,6 @@ func TestClusterExtensionManagerFailed(t *testing.T) { require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) - t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) - require.NotNil(t, unpackedCond) - require.Equal(t, metav1.ConditionTrue, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason) - t.Log("By checking the expected installed conditions") installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) require.NotNil(t, installedCond) @@ -510,12 +495,6 @@ func TestClusterExtensionManagedContentCacheWatchFail(t *testing.T) { require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) - t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) - require.NotNil(t, unpackedCond) - require.Equal(t, metav1.ConditionTrue, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason) - t.Log("By checking the expected installed conditions") installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) require.NotNil(t, installedCond) @@ -607,12 +586,6 @@ func TestClusterExtensionInstallationSucceeds(t *testing.T) { require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason) require.Equal(t, "resolved to \"quay.io/operatorhubio/prometheus@fake1.0.0\"", resolvedCond.Message) - t.Log("By checking the expected unpacked conditions") - unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) - require.NotNil(t, unpackedCond) - require.Equal(t, metav1.ConditionTrue, unpackedCond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason) - t.Log("By checking the expected installed conditions") installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) require.NotNil(t, installedCond) diff --git a/internal/controllers/common_controller.go b/internal/controllers/common_controller.go index d03644d76..66a2d1e24 100644 --- a/internal/controllers/common_controller.go +++ b/internal/controllers/common_controller.go @@ -70,30 +70,6 @@ func setInstalledStatusConditionFailed(ext *ocv1alpha1.ClusterExtension, message }) } -func setStatusUnpackFailed(ext *ocv1alpha1.ClusterExtension, message string) { - setInstallStatus(ext, nil) - apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeUnpacked, - Status: metav1.ConditionFalse, - Reason: ocv1alpha1.ReasonFailed, - Message: message, - ObservedGeneration: ext.GetGeneration(), - }) -} - -func setStatusUnpacked(ext *ocv1alpha1.ClusterExtension, message string) { - if message == "" { - message = "unpack successful" - } - apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{ - Type: ocv1alpha1.TypeUnpacked, - Status: metav1.ConditionTrue, - Reason: ocv1alpha1.ReasonSuccess, - Message: message, - ObservedGeneration: ext.GetGeneration(), - }) -} - func setResolutionStatus(ext *ocv1alpha1.ClusterExtension, resStatus *ocv1alpha1.ClusterExtensionResolutionStatus) { ext.Status.Resolution = resStatus } diff --git a/test/e2e/cluster_extension_install_test.go b/test/e2e/cluster_extension_install_test.go index cff9f1b6a..8dc016704 100644 --- a/test/e2e/cluster_extension_install_test.go +++ b/test/e2e/cluster_extension_install_test.go @@ -284,18 +284,6 @@ func TestClusterExtensionInstallRegistry(t *testing.T) { ) }, pollDuration, pollInterval) - t.Log("By eventually reporting a successful unpacked") - require.EventuallyWithT(t, func(ct *assert.CollectT) { - assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) - if !assert.NotNil(ct, cond) { - return - } - assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) - assert.Regexp(ct, "^unpacked .* successfully", cond.Message) - }, pollDuration, pollInterval) - t.Log("By eventually reporting no longer progressing") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) @@ -968,18 +956,6 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes ) }, pollDuration, pollInterval) - t.Log("By eventually reporting a successful unpacked") - require.EventuallyWithT(t, func(ct *assert.CollectT) { - assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked) - if !assert.NotNil(ct, cond) { - return - } - assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) - assert.Regexp(ct, "^unpacked .* successfully", cond.Message) - }, pollDuration, pollInterval) - t.Log("By eventually reporting Progressing == True with Reason Retrying") require.EventuallyWithT(t, func(ct *assert.CollectT) { assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))