Ensure reconcile ticker stops on shutdown

Otherwise this ticker could run forever (or until the process exits).
This commit is contained in:
Brian Goff
2018-12-10 10:32:55 -08:00
parent ee2735541a
commit e6ca19d059

View File

@@ -106,14 +106,15 @@ func New(ctx context.Context, cfg Config) (s *Server, retErr error) {
return s, err return s, err
} }
tick := time.Tick(5 * time.Second)
go func() { go func() {
tick := time.NewTicker(5 * time.Second)
defer tick.Stop()
for { for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return return
case <-tick: case <-tick.C:
ctx, span := trace.StartSpan(ctx, "syncActualState") ctx, span := trace.StartSpan(ctx, "syncActualState")
s.updateNode(ctx) s.updateNode(ctx)
s.updatePodStatuses(ctx) s.updatePodStatuses(ctx)