Commit 9a177911 authored by Xiang Li's avatar Xiang Li

daemon/controller.go: refactor worker

parent 411696d5
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"time" "time"
"fmt" "fmt"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
...@@ -239,7 +240,7 @@ func (dsc *DaemonSetsController) Run(workers int, stopCh <-chan struct{}) { ...@@ -239,7 +240,7 @@ func (dsc *DaemonSetsController) Run(workers int, stopCh <-chan struct{}) {
go dsc.podController.Run(stopCh) go dsc.podController.Run(stopCh)
go dsc.nodeController.Run(stopCh) go dsc.nodeController.Run(stopCh)
for i := 0; i < workers; i++ { 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 { if dsc.internalPodInformer != nil {
...@@ -251,19 +252,17 @@ func (dsc *DaemonSetsController) Run(workers int, stopCh <-chan struct{}) { ...@@ -251,19 +252,17 @@ func (dsc *DaemonSetsController) Run(workers int, stopCh <-chan struct{}) {
dsc.queue.ShutDown() dsc.queue.ShutDown()
} }
func (dsc *DaemonSetsController) worker() { func (dsc *DaemonSetsController) runWorker() {
for { for {
func() { dsKey, quit := dsc.queue.Get()
dsKey, quit := dsc.queue.Get() if quit {
if quit { continue
return }
} err := dsc.syncHandler(dsKey.(string))
defer dsc.queue.Done(dsKey) if err != nil {
err := dsc.syncHandler(dsKey.(string)) glog.Errorf("Error syncing daemon set with key %s: %v", dsKey.(string), err)
if err != nil { }
glog.Errorf("Error syncing daemon set with key %s: %v", dsKey.(string), err) dsc.queue.Done(dsKey)
}
}()
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment