Skip to content

Commit 871c883

Browse files
authored
Simplify status condition reasons (#1241)
Signed-off-by: Catherine Chan-Tse <[email protected]>
1 parent bded2c2 commit 871c883

File tree

7 files changed

+33
-51
lines changed

7 files changed

+33
-51
lines changed

api/v1alpha1/clusterextension_types.go

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -425,19 +425,11 @@ const (
425425
TypeBundleDeprecated = "BundleDeprecated"
426426
TypeUnpacked = "Unpacked"
427427

428-
ReasonErrorGettingClient = "ErrorGettingClient"
429-
ReasonBundleLoadFailed = "BundleLoadFailed"
430-
431-
ReasonInstallationFailed = "InstallationFailed"
432-
ReasonResolutionFailed = "ResolutionFailed"
433-
434-
ReasonSuccess = "Success"
435-
ReasonDeprecated = "Deprecated"
436-
ReasonUpgradeFailed = "UpgradeFailed"
437-
438-
ReasonUnpackSuccess = "UnpackSuccess"
439-
ReasonUnpackFailed = "UnpackFailed"
428+
ReasonSuccess = "Succeeded"
429+
ReasonDeprecated = "Deprecated"
430+
ReasonFailed = "Failed"
440431

432+
ReasonErrorGettingClient = "ErrorGettingClient"
441433
ReasonErrorGettingReleaseState = "ErrorGettingReleaseState"
442434

443435
ReasonUnverifiable = "Unverifiable"
@@ -460,15 +452,10 @@ func init() {
460452
)
461453
// TODO(user): add Reasons from above
462454
conditionsets.ConditionReasons = append(conditionsets.ConditionReasons,
463-
ReasonResolutionFailed,
464-
ReasonInstallationFailed,
465455
ReasonSuccess,
466456
ReasonDeprecated,
467-
ReasonUpgradeFailed,
468-
ReasonBundleLoadFailed,
457+
ReasonFailed,
469458
ReasonErrorGettingClient,
470-
ReasonUnpackSuccess,
471-
ReasonUnpackFailed,
472459
ReasonErrorGettingReleaseState,
473460
ReasonUnverifiable,
474461
)
@@ -508,11 +495,9 @@ type ClusterExtensionStatus struct {
508495
// - "Unpacked", represents whether or not the bundle contents have been successfully unpacked
509496
//
510497
// The current set of reasons are:
511-
// - "ResolutionFailed", this reason is set on the "Resolved" condition when an error has occurred during resolution.
512-
// - "InstallationFailed", this reason is set on the "Installed" condition when an error has occurred during installation
513-
// - "Success", this reason is set on the "Resolved" and "Installed" conditions when resolution and installation/upgrading is successful
514-
// - "UnpackSuccess", this reason is set on the "Unpacked" condition when unpacking a bundle's content is successful
515-
// - "UnpackFailed", this reason is set on the "Unpacked" condition when an error has been encountered while unpacking the contents of a bundle
498+
// - "Success", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when unpacking a bundle's content, resolution and installation/upgrading is successful
499+
// - "Failed", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when an error has occurred while unpacking the contents of a bundle, during resolution or installation.
500+
//
516501
//
517502
// +patchMergeKey=type
518503
// +patchStrategy=merge

config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,8 @@ spec:
484484
- "Unpacked", represents whether or not the bundle contents have been successfully unpacked
485485
486486
The current set of reasons are:
487-
- "ResolutionFailed", this reason is set on the "Resolved" condition when an error has occurred during resolution.
488-
- "InstallationFailed", this reason is set on the "Installed" condition when an error has occurred during installation
489-
- "Success", this reason is set on the "Resolved" and "Installed" conditions when resolution and installation/upgrading is successful
490-
- "UnpackSuccess", this reason is set on the "Unpacked" condition when unpacking a bundle's content is successful
491-
- "UnpackFailed", this reason is set on the "Unpacked" condition when an error has been encountered while unpacking the contents of a bundle
487+
- "Success", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when unpacking a bundle's content, resolution and installation/upgrading is successful
488+
- "Failed", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when an error has occurred while unpacking the contents of a bundle, during resolution or installation.
492489
items:
493490
description: Condition contains details for one aspect of the current
494491
state of this API Resource.

docs/refs/api/operator-controller-api-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ _Appears in:_
210210
| --- | --- | --- | --- |
211211
| `install` _[ClusterExtensionInstallStatus](#clusterextensioninstallstatus)_ | | | |
212212
| `resolution` _[ClusterExtensionResolutionStatus](#clusterextensionresolutionstatus)_ | | | |
213-
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#condition-v1-meta) array_ | conditions is a representation of the current state for this ClusterExtension.<br />The status is represented by a set of "conditions".<br /><br />Each condition is generally structured in the following format:<br /> - Type: a string representation of the condition type. More or less the condition "name".<br /> - Status: a string representation of the state of the condition. Can be one of ["True", "False", "Unknown"].<br /> - Reason: a string representation of the reason for the current state of the condition. Typically useful for building automation around particular Type+Reason combinations.<br /> - Message: a human readable message that further elaborates on the state of the condition<br /><br />The current set of condition types are:<br /> - "Installed", represents whether or not the package referenced in the spec.packageName field has been installed<br /> - "Resolved", represents whether or not a bundle was found that satisfies the selection criteria outlined in the spec<br /> - "Deprecated", represents an aggregation of the PackageDeprecated, ChannelDeprecated, and BundleDeprecated condition types.<br /> - "PackageDeprecated", represents whether or not the package specified in the spec.packageName field has been deprecated<br /> - "ChannelDeprecated", represents whether or not the channel specified in spec.channel has been deprecated<br /> - "BundleDeprecated", represents whether or not the bundle installed is deprecated<br /> - "Unpacked", represents whether or not the bundle contents have been successfully unpacked<br /><br />The current set of reasons are:<br /> - "ResolutionFailed", this reason is set on the "Resolved" condition when an error has occurred during resolution.<br /> - "InstallationFailed", this reason is set on the "Installed" condition when an error has occurred during installation<br /> - "Success", this reason is set on the "Resolved" and "Installed" conditions when resolution and installation/upgrading is successful<br /> - "UnpackSuccess", this reason is set on the "Unpacked" condition when unpacking a bundle's content is successful<br /> - "UnpackFailed", this reason is set on the "Unpacked" condition when an error has been encountered while unpacking the contents of a bundle | | |
213+
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#condition-v1-meta) array_ | conditions is a representation of the current state for this ClusterExtension.<br />The status is represented by a set of "conditions".<br /><br />Each condition is generally structured in the following format:<br /> - Type: a string representation of the condition type. More or less the condition "name".<br /> - Status: a string representation of the state of the condition. Can be one of ["True", "False", "Unknown"].<br /> - Reason: a string representation of the reason for the current state of the condition. Typically useful for building automation around particular Type+Reason combinations.<br /> - Message: a human readable message that further elaborates on the state of the condition<br /><br />The current set of condition types are:<br /> - "Installed", represents whether or not the package referenced in the spec.packageName field has been installed<br /> - "Resolved", represents whether or not a bundle was found that satisfies the selection criteria outlined in the spec<br /> - "Deprecated", represents an aggregation of the PackageDeprecated, ChannelDeprecated, and BundleDeprecated condition types.<br /> - "PackageDeprecated", represents whether or not the package specified in the spec.packageName field has been deprecated<br /> - "ChannelDeprecated", represents whether or not the channel specified in spec.channel has been deprecated<br /> - "BundleDeprecated", represents whether or not the bundle installed is deprecated<br /> - "Unpacked", represents whether or not the bundle contents have been successfully unpacked<br /><br />The current set of reasons are:<br /> - "Success", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when unpacking a bundle's content, resolution and installation/upgrading is successful<br /> - "Failed", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when an error has occurred while unpacking the contents of a bundle, during resolution or installation. | | |
214214

215215

216216
#### PreflightConfig

internal/controllers/clusterextension_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
194194
setInstallStatus(ext, nil)
195195
setResolutionStatus(ext, nil)
196196
setResolvedStatusConditionFailed(ext, err.Error())
197-
ensureAllConditionsWithReason(ext, ocv1alpha1.ReasonResolutionFailed, err.Error())
197+
ensureAllConditionsWithReason(ext, ocv1alpha1.ReasonFailed, err.Error())
198198
return ctrl.Result{}, err
199199
}
200200
if finalizeResult.Updated || finalizeResult.StatusUpdated {
@@ -220,7 +220,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
220220
setInstallStatus(ext, nil)
221221
setResolutionStatus(ext, nil)
222222
setResolvedStatusConditionFailed(ext, err.Error())
223-
ensureAllConditionsWithReason(ext, ocv1alpha1.ReasonResolutionFailed, err.Error())
223+
ensureAllConditionsWithReason(ext, ocv1alpha1.ReasonFailed, err.Error())
224224
return ctrl.Result{}, err
225225
}
226226

@@ -263,7 +263,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
263263
switch unpackResult.State {
264264
case rukpaksource.StatePending:
265265
setStatusUnpackFailed(ext, unpackResult.Message)
266-
ensureAllConditionsWithReason(ext, ocv1alpha1.ReasonUnpackFailed, "unpack pending")
266+
ensureAllConditionsWithReason(ext, ocv1alpha1.ReasonFailed, "unpack pending")
267267
return ctrl.Result{}, nil
268268
case rukpaksource.StateUnpacked:
269269
setStatusUnpacked(ext, fmt.Sprintf("unpack successful: %v", unpackResult.Message))

internal/controllers/clusterextension_controller_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestClusterExtensionResolutionFails(t *testing.T) {
8686
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved)
8787
require.NotNil(t, cond)
8888
require.Equal(t, metav1.ConditionFalse, cond.Status)
89-
require.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
89+
require.Equal(t, ocv1alpha1.ReasonFailed, cond.Reason)
9090
require.Equal(t, fmt.Sprintf("no package %q found", pkgName), cond.Message)
9191

9292
verifyInvariants(ctx, t, reconciler.Client, clusterExtension)
@@ -166,7 +166,7 @@ func TestClusterExtensionResolutionSucceeds(t *testing.T) {
166166
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
167167
require.NotNil(t, unpackedCond)
168168
require.Equal(t, metav1.ConditionFalse, unpackedCond.Status)
169-
require.Equal(t, ocv1alpha1.ReasonUnpackFailed, unpackedCond.Reason)
169+
require.Equal(t, ocv1alpha1.ReasonFailed, unpackedCond.Reason)
170170

171171
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
172172
}
@@ -242,7 +242,7 @@ func TestClusterExtensionUnpackFails(t *testing.T) {
242242
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
243243
require.NotNil(t, unpackedCond)
244244
require.Equal(t, metav1.ConditionFalse, unpackedCond.Status)
245-
require.Equal(t, ocv1alpha1.ReasonUnpackFailed, unpackedCond.Reason)
245+
require.Equal(t, ocv1alpha1.ReasonFailed, unpackedCond.Reason)
246246

247247
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
248248
}
@@ -320,7 +320,7 @@ func TestClusterExtensionUnpackUnexpectedState(t *testing.T) {
320320
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
321321
require.NotNil(t, unpackedCond)
322322
require.Equal(t, metav1.ConditionFalse, unpackedCond.Status)
323-
require.Equal(t, ocv1alpha1.ReasonUnpackFailed, unpackedCond.Reason)
323+
require.Equal(t, ocv1alpha1.ReasonFailed, unpackedCond.Reason)
324324

325325
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
326326
}
@@ -402,7 +402,7 @@ func TestClusterExtensionUnpackSucceeds(t *testing.T) {
402402
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
403403
require.NotNil(t, unpackedCond)
404404
require.Equal(t, metav1.ConditionTrue, unpackedCond.Status)
405-
require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason)
405+
require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason)
406406

407407
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
408408
}
@@ -484,13 +484,13 @@ func TestClusterExtensionInstallationFailedApplierFails(t *testing.T) {
484484
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
485485
require.NotNil(t, unpackedCond)
486486
require.Equal(t, metav1.ConditionTrue, unpackedCond.Status)
487-
require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason)
487+
require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason)
488488

489489
t.Log("By checking the expected installed conditions")
490490
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
491491
require.NotNil(t, installedCond)
492492
require.Equal(t, metav1.ConditionFalse, installedCond.Status)
493-
require.Equal(t, ocv1alpha1.ReasonInstallationFailed, installedCond.Reason)
493+
require.Equal(t, ocv1alpha1.ReasonFailed, installedCond.Reason)
494494

495495
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
496496
}
@@ -575,7 +575,7 @@ func TestClusterExtensionManagerFailed(t *testing.T) {
575575
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
576576
require.NotNil(t, unpackedCond)
577577
require.Equal(t, metav1.ConditionTrue, unpackedCond.Status)
578-
require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason)
578+
require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason)
579579

580580
t.Log("By checking the expected installed conditions")
581581
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
@@ -675,7 +675,7 @@ func TestClusterExtensionManagedContentCacheWatchFail(t *testing.T) {
675675
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
676676
require.NotNil(t, unpackedCond)
677677
require.Equal(t, metav1.ConditionTrue, unpackedCond.Status)
678-
require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason)
678+
require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason)
679679

680680
t.Log("By checking the expected installed conditions")
681681
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
@@ -772,7 +772,7 @@ func TestClusterExtensionInstallationSucceeds(t *testing.T) {
772772
unpackedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeUnpacked)
773773
require.NotNil(t, unpackedCond)
774774
require.Equal(t, metav1.ConditionTrue, unpackedCond.Status)
775-
require.Equal(t, ocv1alpha1.ReasonUnpackSuccess, unpackedCond.Reason)
775+
require.Equal(t, ocv1alpha1.ReasonSuccess, unpackedCond.Reason)
776776

777777
t.Log("By checking the expected installed conditions")
778778
installedCond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)

internal/controllers/common_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func setResolvedStatusConditionFailed(ext *ocv1alpha1.ClusterExtension, message
3939
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
4040
Type: ocv1alpha1.TypeResolved,
4141
Status: metav1.ConditionFalse,
42-
Reason: ocv1alpha1.ReasonResolutionFailed,
42+
Reason: ocv1alpha1.ReasonFailed,
4343
Message: message,
4444
ObservedGeneration: ext.GetGeneration(),
4545
})
@@ -61,7 +61,7 @@ func setInstalledStatusConditionFailed(ext *ocv1alpha1.ClusterExtension, message
6161
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
6262
Type: ocv1alpha1.TypeInstalled,
6363
Status: metav1.ConditionFalse,
64-
Reason: ocv1alpha1.ReasonInstallationFailed,
64+
Reason: ocv1alpha1.ReasonFailed,
6565
Message: message,
6666
ObservedGeneration: ext.GetGeneration(),
6767
})
@@ -72,7 +72,7 @@ func setStatusUnpackFailed(ext *ocv1alpha1.ClusterExtension, message string) {
7272
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
7373
Type: ocv1alpha1.TypeUnpacked,
7474
Status: metav1.ConditionFalse,
75-
Reason: ocv1alpha1.ReasonUnpackFailed,
75+
Reason: ocv1alpha1.ReasonFailed,
7676
Message: message,
7777
ObservedGeneration: ext.GetGeneration(),
7878
})
@@ -82,7 +82,7 @@ func setStatusUnpacked(ext *ocv1alpha1.ClusterExtension, message string) {
8282
apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
8383
Type: ocv1alpha1.TypeUnpacked,
8484
Status: metav1.ConditionTrue,
85-
Reason: ocv1alpha1.ReasonUnpackSuccess,
85+
Reason: ocv1alpha1.ReasonSuccess,
8686
Message: message,
8787
ObservedGeneration: ext.GetGeneration(),
8888
})

test/e2e/cluster_extension_install_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
273273
return
274274
}
275275
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
276-
assert.Equal(ct, ocv1alpha1.ReasonUnpackSuccess, cond.Reason)
276+
assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason)
277277
assert.Contains(ct, cond.Message, "unpack successful")
278278
}, pollDuration, pollInterval)
279279

@@ -324,7 +324,7 @@ func TestClusterExtensionInstallRegistryMultipleBundles(t *testing.T) {
324324
return
325325
}
326326
assert.Equal(ct, metav1.ConditionFalse, cond.Status)
327-
assert.Equal(ct, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
327+
assert.Equal(ct, ocv1alpha1.ReasonFailed, cond.Reason)
328328
assert.Contains(ct, cond.Message, "in multiple catalogs with the same priority [operatorhubio test-catalog]")
329329
assert.Nil(ct, clusterExtension.Status.Resolution)
330330
}, pollDuration, pollInterval)
@@ -393,7 +393,7 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) {
393393
if !assert.NotNil(ct, cond) {
394394
return
395395
}
396-
assert.Equal(ct, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
396+
assert.Equal(ct, ocv1alpha1.ReasonFailed, cond.Reason)
397397
assert.Equal(ct, "error upgrading from currently installed version \"1.0.0\": no bundles found for package \"prometheus\" matching version \"1.2.0\"", cond.Message)
398398
assert.Empty(ct, clusterExtension.Status.Resolution)
399399
}, pollDuration, pollInterval)
@@ -848,7 +848,7 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes
848848
return
849849
}
850850
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
851-
assert.Equal(ct, ocv1alpha1.ReasonUnpackSuccess, cond.Reason)
851+
assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason)
852852
assert.Contains(ct, cond.Message, "unpack successful")
853853
}, pollDuration, pollInterval)
854854

@@ -860,7 +860,7 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes
860860
return
861861
}
862862
assert.Equal(ct, metav1.ConditionFalse, cond.Status)
863-
assert.Equal(ct, ocv1alpha1.ReasonInstallationFailed, cond.Reason)
863+
assert.Equal(ct, ocv1alpha1.ReasonFailed, cond.Reason)
864864
assert.Contains(ct, cond.Message, "forbidden")
865865
}, pollDuration, pollInterval)
866866

0 commit comments

Comments
 (0)