Skip to content

Commit 1aae1d5

Browse files
committed
Agents stop update managedcluster status when clock is out of sync.
Signed-off-by: xuezhaojun <[email protected]>
1 parent 17e05da commit 1aae1d5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pkg/registration/hub/lease/clocksynccontroller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func (c *clockSyncController) sync(ctx context.Context, syncCtx factory.SyncCont
104104
}
105105
// When the agent's lease get renewed, the "now" on hub should close to the RenewTime on agent.
106106
// If the two time are not close(over 1 lease duration), we assume the clock is out of sync.
107+
// Then, if the Clock is out of sync, the agent will not be able to update the status of managed cluster.
107108
oneLeaseDuration := time.Duration(LeaseDurationSeconds) * time.Second
108109
if err := c.updateClusterStatusClockSynced(ctx, cluster,
109110
now.Sub(observedLease.Spec.RenewTime.Time) < oneLeaseDuration && observedLease.Spec.RenewTime.Time.Sub(now) < oneLeaseDuration); err != nil {

pkg/registration/spoke/managedcluster/status_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ func (c *managedClusterStatusController) sync(ctx context.Context, syncCtx facto
121121
}
122122
}
123123

124+
// check if managedcluster's clock is out of sync, if so, the agent will not be able to update the status of managed cluster.
125+
clockSynced := meta.IsStatusConditionTrue(newCluster.Status.Conditions, clusterv1.ManagedClusterConditionClockSynced)
126+
if !clockSynced {
127+
return nil
128+
}
129+
124130
changed, err := c.patcher.PatchStatus(ctx, newCluster, newCluster.Status, cluster.Status)
125131
if err != nil {
126132
errs = append(errs, err)

0 commit comments

Comments
 (0)