Skip to content

Commit 5cdbd9d

Browse files
committed
remove unpacked status
1 parent 679e4ab commit 5cdbd9d

File tree

5 files changed

+5
-107
lines changed

5 files changed

+5
-107
lines changed

api/v1alpha1/clusterextension_types.go

-2
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ const (
422422
TypePackageDeprecated = "PackageDeprecated"
423423
TypeChannelDeprecated = "ChannelDeprecated"
424424
TypeBundleDeprecated = "BundleDeprecated"
425-
TypeUnpacked = "Unpacked"
426425

427426
ReasonSuccess = "Succeeded"
428427
ReasonDeprecated = "Deprecated"
@@ -446,7 +445,6 @@ func init() {
446445
TypePackageDeprecated,
447446
TypeChannelDeprecated,
448447
TypeBundleDeprecated,
449-
TypeUnpacked,
450448
TypeProgressing,
451449
)
452450
// TODO(user): add Reasons from above

internal/controllers/clusterextension_controller.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,14 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
267267
l.V(1).Info("unpacking resolved bundle")
268268
unpackResult, err := r.Unpacker.Unpack(ctx, bundleSource)
269269
if err != nil {
270-
setStatusUnpackFailed(ext, err.Error())
271270
// Wrap the error passed to this with the resolution information until we have successfully
272271
// installed since we intend for the progressing condition to replace the resolved condition
273272
// and will be removing the .status.resolution field from the ClusterExtension status API
274273
setStatusProgressing(ext, wrapErrorWithResolutionInfo(resolvedBundleMetadata, err))
275274
return ctrl.Result{}, err
276275
}
277276

278-
switch unpackResult.State {
279-
case rukpaksource.StateUnpacked:
280-
setStatusUnpacked(ext, unpackResult.Message)
281-
default:
277+
if unpackResult.State != rukpaksource.StateUnpacked {
282278
panic(fmt.Sprintf("unexpected unpack state %q", unpackResult.State))
283279
}
284280

internal/controllers/clusterextension_controller_test.go

+4-52
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,12 @@ func TestClusterExtensionResolutionSuccessfulUnpackFails(t *testing.T) {
150150
})
151151
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey})
152152
require.Equal(t, ctrl.Result{}, res)
153-
require.Error(t, err)
154153

155154
t.Log("By fetching updated cluster extension after reconcile")
156155
require.NoError(t, cl.Get(ctx, extKey, clusterExtension))
157156

158157
t.Log("By checking the status fields")
159-
expectedBundleMetadata := ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}
160-
require.Equal(t, expectedBundleMetadata, clusterExtension.Status.Resolution.Bundle)
158+
require.Equal(t, ocv1alpha1.BundleMetadata{Name: "prometheus.v1.0.0", Version: "1.0.0"}, clusterExtension.Status.Resolution.Bundle)
161159
require.Empty(t, clusterExtension.Status.Install)
162160

163161
t.Log("By checking the expected conditions")
@@ -167,18 +165,6 @@ func TestClusterExtensionResolutionSuccessfulUnpackFails(t *testing.T) {
167165
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
168166
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", resolvedCond.Message)
169167

170-
t.Log("By checking the expected unpacked conditions")
171-
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
172-
require.NotNil(t, unpackedCond)
173-
require.Equal(t, metav1.ConditionFalse, unpackedCond.Status)
174-
require.Equal(t, ocv1alpha1.ReasonFailed, unpackedCond.Reason)
175-
176-
progressingCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeProgressing)
177-
require.NotNil(t, progressingCond)
178-
require.Equal(t, metav1.ConditionTrue, progressingCond.Status)
179-
require.Equal(t, ocv1alpha1.ReasonRetrying, progressingCond.Reason)
180-
require.Contains(t, progressingCond.Message, fmt.Sprintf("for resolved bundle %q with version %q", expectedBundleMetadata.Name, expectedBundleMetadata.Version))
181-
182168
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
183169
}
184170

@@ -233,9 +219,12 @@ func TestClusterExtensionUnpackUnexpectedState(t *testing.T) {
233219
Image: "quay.io/operatorhubio/[email protected]",
234220
}, &v, nil, nil
235221
})
222+
236223
require.Panics(t, func() {
237224
_, _ = reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey})
238225
}, "reconciliation should panic on unknown unpack state")
226+
227+
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
239228
}
240229

241230
func TestClusterExtensionResolutionAndUnpackSuccessfulApplierFails(t *testing.T) {
@@ -312,25 +301,6 @@ func TestClusterExtensionResolutionAndUnpackSuccessfulApplierFails(t *testing.T)
312301
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
313302
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", resolvedCond.Message)
314303

315-
t.Log("By checking the expected unpacked conditions")
316-
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
317-
require.NotNil(t, unpackedCond)
318-
require.Equal(t, metav1.ConditionTrue, unpackedCond.Status)
319-
require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason)
320-
321-
t.Log("By checking the expected installed conditions")
322-
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
323-
require.NotNil(t, installedCond)
324-
require.Equal(t, metav1.ConditionFalse, installedCond.Status)
325-
require.Equal(t, ocv1alpha1.ReasonFailed, installedCond.Reason)
326-
327-
t.Log("By checking the expected progressing conditions")
328-
progressingCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeProgressing)
329-
require.NotNil(t, progressingCond)
330-
require.Equal(t, metav1.ConditionTrue, progressingCond.Status)
331-
require.Equal(t, ocv1alpha1.ReasonRetrying, progressingCond.Reason)
332-
require.Contains(t, progressingCond.Message, fmt.Sprintf("for resolved bundle %q with version %q", expectedBundleMetadata.Name, expectedBundleMetadata.Version))
333-
334304
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
335305
}
336306

@@ -410,12 +380,6 @@ func TestClusterExtensionManagerFailed(t *testing.T) {
410380
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
411381
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", resolvedCond.Message)
412382

413-
t.Log("By checking the expected unpacked conditions")
414-
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
415-
require.NotNil(t, unpackedCond)
416-
require.Equal(t, metav1.ConditionTrue, unpackedCond.Status)
417-
require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason)
418-
419383
t.Log("By checking the expected installed conditions")
420384
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
421385
require.NotNil(t, installedCond)
@@ -510,12 +474,6 @@ func TestClusterExtensionManagedContentCacheWatchFail(t *testing.T) {
510474
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
511475
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", resolvedCond.Message)
512476

513-
t.Log("By checking the expected unpacked conditions")
514-
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
515-
require.NotNil(t, unpackedCond)
516-
require.Equal(t, metav1.ConditionTrue, unpackedCond.Status)
517-
require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason)
518-
519477
t.Log("By checking the expected installed conditions")
520478
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
521479
require.NotNil(t, installedCond)
@@ -607,12 +565,6 @@ func TestClusterExtensionInstallationSucceeds(t *testing.T) {
607565
require.Equal(t, ocv1alpha1.ReasonSuccess, resolvedCond.Reason)
608566
require.Equal(t, "resolved to \"quay.io/operatorhubio/[email protected]\"", resolvedCond.Message)
609567

610-
t.Log("By checking the expected unpacked conditions")
611-
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
612-
require.NotNil(t, unpackedCond)
613-
require.Equal(t, metav1.ConditionTrue, unpackedCond.Status)
614-
require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason)
615-
616568
t.Log("By checking the expected installed conditions")
617569
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
618570
require.NotNil(t, installedCond)

internal/controllers/common_controller.go

-24
Original file line numberDiff line numberDiff line change
@@ -70,30 +70,6 @@ func setInstalledStatusConditionFailed(ext *ocv1alpha1.ClusterExtension, message
7070
})
7171
}
7272

73-
func setStatusUnpackFailed(ext *ocv1alpha1.ClusterExtension, message string) {
74-
setInstallStatus(ext, nil)
75-
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
76-
Type: ocv1alpha1.TypeUnpacked,
77-
Status: metav1.ConditionFalse,
78-
Reason: ocv1alpha1.ReasonFailed,
79-
Message: message,
80-
ObservedGeneration: ext.GetGeneration(),
81-
})
82-
}
83-
84-
func setStatusUnpacked(ext *ocv1alpha1.ClusterExtension, message string) {
85-
if message == "" {
86-
message = "unpack successful"
87-
}
88-
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
89-
Type: ocv1alpha1.TypeUnpacked,
90-
Status: metav1.ConditionTrue,
91-
Reason: ocv1alpha1.ReasonSuccess,
92-
Message: message,
93-
ObservedGeneration: ext.GetGeneration(),
94-
})
95-
}
96-
9773
func setResolutionStatus(ext *ocv1alpha1.ClusterExtension, resStatus *ocv1alpha1.ClusterExtensionResolutionStatus) {
9874
ext.Status.Resolution = resStatus
9975
}

test/e2e/cluster_extension_install_test.go

-24
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,6 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
284284
)
285285
}, pollDuration, pollInterval)
286286

287-
t.Log("By eventually reporting a successful unpacked")
288-
require.EventuallyWithT(t, func(ct *assert.CollectT) {
289-
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
290-
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
291-
if !assert.NotNil(ct, cond) {
292-
return
293-
}
294-
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
295-
assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason)
296-
assert.Regexp(ct, "^unpacked .* successfully", cond.Message)
297-
}, pollDuration, pollInterval)
298-
299287
t.Log("By eventually reporting no longer progressing")
300288
require.EventuallyWithT(t, func(ct *assert.CollectT) {
301289
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
@@ -968,18 +956,6 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes
968956
)
969957
}, pollDuration, pollInterval)
970958

971-
t.Log("By eventually reporting a successful unpacked")
972-
require.EventuallyWithT(t, func(ct *assert.CollectT) {
973-
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
974-
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
975-
if !assert.NotNil(ct, cond) {
976-
return
977-
}
978-
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
979-
assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason)
980-
assert.Regexp(ct, "^unpacked .* successfully", cond.Message)
981-
}, pollDuration, pollInterval)
982-
983959
t.Log("By eventually reporting Progressing == True with Reason Retrying")
984960
require.EventuallyWithT(t, func(ct *assert.CollectT) {
985961
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))

0 commit comments

Comments
 (0)