Skip to content

Commit 851af81

Browse files
committed
OPTIM/MINOR: schedule: wait until last command is done, before starting they new refresh cycle
1 parent ab37fc0 commit 851af81

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pkg/controller/monitor.go

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ func (c *HAProxyController) SyncData() {
3737
if hadChanges || instance.NeedReload() {
3838
c.updateHAProxy()
3939
hadChanges = false
40+
if job.EventProcessed != nil {
41+
close(job.EventProcessed)
42+
}
4043
continue
4144
}
4245
case k8ssync.CR_GLOBAL:

pkg/k8s/main.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ func (k k8s) MonitorChanges(eventChan chan k8ssync.SyncDataEvent, stop chan stru
179179
eventChan <- k8ssync.SyncDataEvent{SyncType: k8ssync.COMMAND}
180180
for {
181181
time.Sleep(syncPeriod)
182-
eventChan <- k8ssync.SyncDataEvent{SyncType: k8ssync.COMMAND}
182+
ep := make(chan struct{})
183+
eventChan <- k8ssync.SyncDataEvent{
184+
SyncType: k8ssync.COMMAND,
185+
EventProcessed: ep,
186+
}
187+
<-ep
183188
}
184189
}
185190

0 commit comments

Comments
 (0)