Skip to content

Commit 34d1ae7

Browse files
committed
Set Ready condition to Unknown for offline clusters
This better reflects what is then known about workloads running in such clusters than `False`.
1 parent 00d6ef0 commit 34d1ae7

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

internal/cmd/agent/deployer/monitor/condition.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ func (c Cond) IsFalse(obj interface{}) bool {
4444
return getStatus(obj, string(c)) == "False"
4545
}
4646

47+
func (c Cond) Unknown(obj interface{}) {
48+
setStatus(obj, string(c), "Unknown")
49+
}
50+
51+
func (c Cond) IsUnknown(obj interface{}) bool {
52+
return getStatus(obj, string(c)) == "Unknown"
53+
}
54+
4755
func (c Cond) Reason(obj interface{}, reason string) {
4856
cond := findOrCreateCond(obj, string(c))
4957
getFieldValue(cond, "Reason").SetString(reason)

internal/cmd/controller/clustermonitor/monitor.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,10 @@ func UpdateOfflineBundleDeployments(ctx context.Context, c client.Client, thresh
115115
for _, cond := range bd.Status.Conditions {
116116
switch cond.Type {
117117
case "Ready":
118-
// FIXME: avoid relying on agent pkg for this?
119118
mc := monitor.Cond(v1alpha1.BundleDeploymentConditionReady)
120119
mc.SetError(&t.Status, "Cluster offline", errors.New(offlineMsg))
121120
mc.Unknown(&t.Status)
122121
// XXX: do we want to set Deployed and Installed conditions as well?
123-
// XXX: should we set conditions to `Unknown`?
124122
case "Monitored":
125123
mc := monitor.Cond(v1alpha1.BundleDeploymentConditionMonitored)
126124
mc.SetError(&t.Status, "Cluster offline", errors.New(offlineMsg))

internal/cmd/controller/clustermonitor/monitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (m BDStatusMatcher) Matches(x interface{}) bool {
4242
if cond.Type == "Ready" {
4343
foundReady = true
4444

45-
if cond.Status != "False" ||
45+
if cond.Status != "Unknown" ||
4646
!strings.Contains(cond.Reason, "offline") ||
4747
!strings.Contains(cond.Message, "offline") {
4848
return false

0 commit comments

Comments
 (0)