Skip to content

Commit f4be469

Browse files
committed
pkg/controller/status/status: Set reasons for conditions
We've been light on reasons for expected conditions like Progressing=False since 80ab923 (Initial support operator commit, 2019-04-02). But if we feel like we have a message we want to set to help humans understand the condition, we should be setting a reason string for machines too. AsExpected follows the library-go precedent [1]. The "Degraded" reason I'm adding here isn't a great fit for a progressing reason, but does match the current logic used to set Progressing=True. The insights operator doesn't actually supply any in-cluster APIs beyond ClusterOperator as far as I can tell, so it's not clear to me what sort of progressing it would do except its internal intialization (which I give a new "Initializing" reason). But adding an odd reason seemed easy enough, and we can always circle back later and remove this Progressing=False case if we decide we don't need it. [1]: https://github.com/openshift/library-go/blob/94c59dec54be25c8527e51e8c0a885712aeb01b5/pkg/operator/status/condition.go#L67
1 parent ff9de18 commit f4be469

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

docs/insights-archive-sample/config/clusteroperator/insights

+4
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,26 @@
1515
{
1616
"type": "Degraded",
1717
"status": "False",
18+
"reason": "AsExpected",
1819
"lastTransitionTime": "2020-03-18T12:14:52Z"
1920
},
2021
{
2122
"type": "Available",
2223
"status": "True",
24+
"reason": "AsExpected",
2325
"lastTransitionTime": "2020-03-18T12:14:52Z"
2426
},
2527
{
2628
"type": "Progressing",
2729
"status": "False",
2830
"lastTransitionTime": "2020-03-18T12:16:52Z",
31+
"reason": "AsExpected",
2932
"message": "Monitoring the cluster"
3033
},
3134
{
3235
"type": "Disabled",
3336
"status": "False",
37+
"reason": "AsExpected",
3438
"lastTransitionTime": "2020-03-18T12:16:52Z"
3539
}
3640
],

pkg/controller/status/status.go

+7
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func (c *Controller) merge(existing *configv1.ClusterOperator) *configv1.Cluster
208208
setOperatorStatusCondition(&existing.Status.Conditions, configv1.ClusterOperatorStatusCondition{
209209
Type: configv1.OperatorDegraded,
210210
Status: configv1.ConditionFalse,
211+
Reason: "AsExpected",
211212
})
212213
}
213214

@@ -224,6 +225,7 @@ func (c *Controller) merge(existing *configv1.ClusterOperator) *configv1.Cluster
224225
setOperatorStatusCondition(&existing.Status.Conditions, configv1.ClusterOperatorStatusCondition{
225226
Type: OperatorDisabled,
226227
Status: configv1.ConditionFalse,
228+
Reason: "AsExpected",
227229
})
228230
}
229231

@@ -240,6 +242,7 @@ func (c *Controller) merge(existing *configv1.ClusterOperator) *configv1.Cluster
240242
setOperatorStatusCondition(&existing.Status.Conditions, configv1.ClusterOperatorStatusCondition{
241243
Type: configv1.OperatorDegraded,
242244
Status: configv1.ConditionFalse,
245+
Reason: "AsExpected",
243246
})
244247
}
245248

@@ -260,6 +263,7 @@ func (c *Controller) merge(existing *configv1.ClusterOperator) *configv1.Cluster
260263
setOperatorStatusCondition(&existing.Status.Conditions, configv1.ClusterOperatorStatusCondition{
261264
Type: configv1.OperatorAvailable,
262265
Status: configv1.ConditionTrue,
266+
Reason: "AsExpected",
263267
})
264268

265269
// update the Progressing condition with a summary of the current state
@@ -272,6 +276,7 @@ func (c *Controller) merge(existing *configv1.ClusterOperator) *configv1.Cluster
272276
setOperatorStatusCondition(&existing.Status.Conditions, configv1.ClusterOperatorStatusCondition{
273277
Type: configv1.OperatorProgressing,
274278
Status: configv1.ConditionTrue,
279+
Reason: "Initializing",
275280
Message: "Initializing the operator",
276281
})
277282
}
@@ -281,6 +286,7 @@ func (c *Controller) merge(existing *configv1.ClusterOperator) *configv1.Cluster
281286
setOperatorStatusCondition(&existing.Status.Conditions, configv1.ClusterOperatorStatusCondition{
282287
Type: configv1.OperatorProgressing,
283288
Status: configv1.ConditionFalse,
289+
Reason: "Degraded",
284290
Message: "An error has occurred",
285291
})
286292

@@ -299,6 +305,7 @@ func (c *Controller) merge(existing *configv1.ClusterOperator) *configv1.Cluster
299305
setOperatorStatusCondition(&existing.Status.Conditions, configv1.ClusterOperatorStatusCondition{
300306
Type: configv1.OperatorProgressing,
301307
Status: configv1.ConditionFalse,
308+
Reason: "AsExpected",
302309
Message: "Monitoring the cluster",
303310
})
304311
}

pkg/gather/clusterconfig/testdata/clusteroperators.json

+4
Original file line numberDiff line numberDiff line change
@@ -837,22 +837,26 @@
837837
{
838838
"type": "Degraded",
839839
"status": "False",
840+
"reason": "AsExpected",
840841
"lastTransitionTime": "2020-04-17T12:12:48Z"
841842
},
842843
{
843844
"type": "Available",
844845
"status": "True",
846+
"reason": "AsExpected",
845847
"lastTransitionTime": "2020-04-17T12:12:48Z"
846848
},
847849
{
848850
"type": "Progressing",
849851
"status": "False",
852+
"reason": "AsExpected",
850853
"lastTransitionTime": "2020-04-17T12:14:48Z",
851854
"message": "Monitoring the cluster"
852855
},
853856
{
854857
"type": "Disabled",
855858
"status": "False",
859+
"reason": "AsExpected",
856860
"lastTransitionTime": "2020-04-17T12:14:48Z"
857861
}
858862
],

0 commit comments

Comments
 (0)