Skip to content

Commit 4a32093

Browse files
committed
Simplify setting cluster offline and back online from BDs
A cluster should be marked offline if _any_ of its bundle deployments is offline, and back online when all of them are back online. This prevents flapping status updates in case not all bundle deployments have been updated by the cluster monitor.
1 parent 63a964a commit 4a32093

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

internal/cmd/controller/reconciler/cluster_controller.go

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -248,24 +248,18 @@ func (r *ClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
248248

249249
if summary.MessageFromCondition(fleet.ClusterConditionReady, bd.Status.Conditions) == fleet.ClusterOfflineMsg {
250250
// bundle deployment offline, mark cluster offline
251-
if isClusterOffline {
252-
continue
253-
}
254-
255251
isClusterOffline = true
252+
}
253+
}
256254

257-
for _, c := range offlineConds {
258-
cond := monitor.Cond(c)
259-
cond.SetError(&cluster.Status, "Cluster offline", errors.New(fleet.ClusterOfflineMsg))
260-
cond.Unknown(&cluster.Status)
261-
}
262-
263-
} else if summary.MessageFromCondition(fleet.ClusterConditionReady, cluster.Status.Conditions) == fleet.ClusterOfflineMsg {
264-
// bundle deployment online, mark offline cluster back online
265-
for _, c := range offlineConds {
266-
cond := monitor.Cond(c)
267-
cond.SetError(&cluster.Status, "", nil)
268-
}
255+
for _, c := range offlineConds {
256+
cond := monitor.Cond(c)
257+
if isClusterOffline {
258+
cond.SetError(&cluster.Status, "Cluster offline", errors.New(fleet.ClusterOfflineMsg))
259+
cond.Unknown(&cluster.Status)
260+
} else {
261+
// bundle deployments all online, mark offline cluster back online
262+
cond.SetError(&cluster.Status, "", nil)
269263
}
270264
}
271265

0 commit comments

Comments
 (0)