Skip to content

Commit 49d2621

Browse files
authored
Bug 2081997: Fix the clusteroperator conditions values when IO is (#618)
disabled
1 parent e7cc011 commit 49d2621

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pkg/controller/status/controller.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -338,21 +338,21 @@ func updateControllerConditions(cs *conditions, ctrlStatus *controllerStatus,
338338
}
339339

340340
// handle when has errors
341-
if es := ctrlStatus.getStatus(ErrorStatus); es != nil {
341+
if es := ctrlStatus.getStatus(ErrorStatus); es != nil && !ctrlStatus.isDisabled() {
342342
cs.setCondition(configv1.OperatorDegraded, configv1.ConditionTrue, es.reason, es.message, metav1.Time{Time: lastTransition})
343343
} else {
344344
cs.setCondition(configv1.OperatorDegraded, configv1.ConditionFalse, "AsExpected", insightsAvailableMessage, metav1.Now())
345345
}
346346

347347
// handle when upload fails
348-
if ur := ctrlStatus.getStatus(UploadStatus); ur != nil {
348+
if ur := ctrlStatus.getStatus(UploadStatus); ur != nil && !ctrlStatus.isDisabled() {
349349
cs.setCondition(InsightsUploadDegraded, configv1.ConditionTrue, ur.reason, ur.message, metav1.Time{Time: lastTransition})
350350
} else {
351351
cs.removeCondition(InsightsUploadDegraded)
352352
}
353353

354354
// handle when download fails
355-
if ds := ctrlStatus.getStatus(DownloadStatus); ds != nil {
355+
if ds := ctrlStatus.getStatus(DownloadStatus); ds != nil && !ctrlStatus.isDisabled() {
356356
cs.setCondition(InsightsDownloadDegraded, configv1.ConditionTrue, ds.reason, ds.message, metav1.Time{Time: lastTransition})
357357
} else {
358358
cs.removeCondition(InsightsDownloadDegraded)
@@ -385,7 +385,7 @@ func updateControllerConditionsByStatus(cs *conditions, ctrlStatus *controllerSt
385385
}
386386
}
387387

388-
if es := ctrlStatus.getStatus(ErrorStatus); es != nil {
388+
if es := ctrlStatus.getStatus(ErrorStatus); es != nil && !ctrlStatus.isDisabled() {
389389
klog.V(4).Infof("The operator has some internal errors: %s", es.message)
390390
cs.setCondition(configv1.OperatorProgressing, configv1.ConditionFalse, "Degraded", "An error has occurred", metav1.Now())
391391
cs.setCondition(configv1.OperatorAvailable, configv1.ConditionFalse, es.reason, es.message, metav1.Now())
@@ -395,6 +395,9 @@ func updateControllerConditionsByStatus(cs *conditions, ctrlStatus *controllerSt
395395
if ds := ctrlStatus.getStatus(DisabledStatus); ds != nil {
396396
klog.V(4).Infof("The operator is marked as disabled")
397397
cs.setCondition(configv1.OperatorProgressing, configv1.ConditionFalse, ds.reason, ds.message, metav1.Now())
398+
cs.setCondition(configv1.OperatorAvailable, configv1.ConditionFalse, ds.reason, ds.message, metav1.Now())
399+
cs.setCondition(configv1.OperatorUpgradeable, configv1.ConditionTrue, "InsightsUpgradeable",
400+
"Insights operator can be upgraded", metav1.Now())
398401
}
399402

400403
if ctrlStatus.isHealthy() {

pkg/controller/status/status.go

+4
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ func (c *controllerStatus) reset() {
6262
func (c *controllerStatus) isHealthy() bool {
6363
return !c.hasStatus(ErrorStatus)
6464
}
65+
66+
func (c *controllerStatus) isDisabled() bool {
67+
return c.hasStatus(DisabledStatus)
68+
}

0 commit comments

Comments
 (0)