mirror of https://github.com/k3s-io/k3s
daemon/controller.go: refactor worker
parent
411696d5ef
commit
9a1779110c
|
@ -23,6 +23,7 @@ import (
|
|||
"time"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
|
@ -239,7 +240,7 @@ func (dsc *DaemonSetsController) Run(workers int, stopCh <-chan struct{}) {
|
|||
go dsc.podController.Run(stopCh)
|
||||
go dsc.nodeController.Run(stopCh)
|
||||
for i := 0; i < workers; i++ {
|
||||
go wait.Until(dsc.worker, time.Second, stopCh)
|
||||
go wait.Until(dsc.runWorker, time.Second, stopCh)
|
||||
}
|
||||
|
||||
if dsc.internalPodInformer != nil {
|
||||
|
@ -251,19 +252,17 @@ func (dsc *DaemonSetsController) Run(workers int, stopCh <-chan struct{}) {
|
|||
dsc.queue.ShutDown()
|
||||
}
|
||||
|
||||
func (dsc *DaemonSetsController) worker() {
|
||||
func (dsc *DaemonSetsController) runWorker() {
|
||||
for {
|
||||
func() {
|
||||
dsKey, quit := dsc.queue.Get()
|
||||
if quit {
|
||||
return
|
||||
continue
|
||||
}
|
||||
defer dsc.queue.Done(dsKey)
|
||||
err := dsc.syncHandler(dsKey.(string))
|
||||
if err != nil {
|
||||
glog.Errorf("Error syncing daemon set with key %s: %v", dsKey.(string), err)
|
||||
}
|
||||
}()
|
||||
dsc.queue.Done(dsKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue