Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Remove unpacked status #1309

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions api/v1alpha1/clusterextension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ const (
TypePackageDeprecated = "PackageDeprecated"
TypeChannelDeprecated = "ChannelDeprecated"
TypeBundleDeprecated = "BundleDeprecated"
TypeUnpacked = "Unpacked"

ReasonSuccess = "Succeeded"
ReasonDeprecated = "Deprecated"
Expand All @@ -446,7 +445,6 @@ func init() {
TypePackageDeprecated,
TypeChannelDeprecated,
TypeBundleDeprecated,
TypeUnpacked,
TypeProgressing,
)
// TODO(user): add Reasons from above
Expand Down
6 changes: 1 addition & 5 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,14 @@ 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
setStatusProgressing(ext, wrapErrorWithResolutionInfo(resolvedBundleMetadata, err))
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))
}

Expand Down
33 changes: 3 additions & 30 deletions internal/controllers/clusterextension_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ func TestClusterExtensionResolutionSuccessfulUnpackFails(t *testing.T) {
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", 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)
Expand Down Expand Up @@ -233,9 +227,12 @@ func TestClusterExtensionUnpackUnexpectedState(t *testing.T) {
Image: "quay.io/operatorhubio/[email protected]",
}, &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{}))
Comment on lines +234 to +235
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to keep around - I must've been a bit heavy handed on my removal of logic in this test and removed this

}

func TestClusterExtensionResolutionAndUnpackSuccessfulApplierFails(t *testing.T) {
Expand Down Expand Up @@ -312,12 +309,6 @@ func TestClusterExtensionResolutionAndUnpackSuccessfulApplierFails(t *testing.T)
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", 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)
Expand Down Expand Up @@ -410,12 +401,6 @@ func TestClusterExtensionManagerFailed(t *testing.T) {
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", 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)
Expand Down Expand Up @@ -510,12 +495,6 @@ func TestClusterExtensionManagedContentCacheWatchFail(t *testing.T) {
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", 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)
Expand Down Expand Up @@ -607,12 +586,6 @@ func TestClusterExtensionInstallationSucceeds(t *testing.T) {
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", 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)
Expand Down
24 changes: 0 additions & 24 deletions internal/controllers/common_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
24 changes: 0 additions & 24 deletions test/e2e/cluster_extension_install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
Loading