func()

in pkg/controller/liveness/liveness.go [244:266]


func (hc *HealthCheck) checkSyncAllTimeOut() error {
	hc.mutex.RLock()
	defer hc.mutex.RUnlock()
	lastSyncAll := hc.lastActivity[SynchronizeAll]
	lastSuccessSyncAll := hc.lastSuccessSync.runTime
	now := time.Now()
	activityTimedOut := now.After(lastSyncAll.Add(hc.syncActivityTimeout))
	successTimedOut := now.After(lastSuccessSyncAll.Add(hc.syncSuccessTimeout))

	if activityTimedOut {
		timeoutDelta := now.Sub(lastSyncAll) - hc.syncActivityTimeout
		return fmt.Errorf(
			`last synchronizeAll activity %s ago, which exceeds the %s timeout by %s`,
			now.Sub(lastSyncAll), hc.syncActivityTimeout, timeoutDelta)
	} else if successTimedOut {
		timeoutDelta := now.Sub(hc.lastSuccessSync.runTime) - hc.syncSuccessTimeout
		return fmt.Errorf(
			"last synchronizeAll success activity %s ago, which exceeds "+
				"the %s timeout by %s",
			now.Sub(hc.lastSuccessSync.runTime), hc.syncSuccessTimeout, timeoutDelta)
	}
	return nil
}