|
|
|
@ -93,10 +93,12 @@ func (s *StateSyncer) Run() {
|
|
|
|
|
|
|
|
|
|
Sync: |
|
|
|
|
for { |
|
|
|
|
switch err := s.State.UpdateSyncState(); { |
|
|
|
|
// update the sync status
|
|
|
|
|
err := s.State.UpdateSyncState() |
|
|
|
|
if err == nil { |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// update sync status failed
|
|
|
|
|
case err != nil: |
|
|
|
|
s.Logger.Printf("[ERR] agent: failed to sync remote state: %v", err) |
|
|
|
|
|
|
|
|
|
// retry updating sync status after some time or when a consul
|
|
|
|
@ -104,7 +106,7 @@ Sync:
|
|
|
|
|
select { |
|
|
|
|
|
|
|
|
|
// consul server added to cluster.
|
|
|
|
|
// retry sooner than retryFailIntv to converge cluster sooner
|
|
|
|
|
// retry sooner than retryFailIntv to converge cluster quicker
|
|
|
|
|
// but stagger delay to avoid thundering herd
|
|
|
|
|
case <-s.ServerUpCh: |
|
|
|
|
select { |
|
|
|
@ -120,13 +122,12 @@ Sync:
|
|
|
|
|
case <-s.ShutdownCh: |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// update sync status OK
|
|
|
|
|
default: |
|
|
|
|
// force-trigger sync to pickup any changes
|
|
|
|
|
// Force-trigger sync to pickup any changes
|
|
|
|
|
s.triggerSync() |
|
|
|
|
|
|
|
|
|
// do partial syncs until it is time for a full sync again
|
|
|
|
|
// Wait for sync events
|
|
|
|
|
for { |
|
|
|
|
select { |
|
|
|
|
// todo(fs): why don't we honor the ServerUpCh here as well?
|
|
|
|
@ -140,7 +141,7 @@ Sync:
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
case <-time.After(s.Interval + stagger(s.Interval)): |
|
|
|
|
continue Sync |
|
|
|
|
goto Sync |
|
|
|
|
|
|
|
|
|
case <-s.TriggerCh: |
|
|
|
|
if s.Paused() { |
|
|
|
@ -154,8 +155,6 @@ Sync:
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Pause temporarily disables sync runs.
|
|
|
|
|