mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #26867 from xiang90/daemon
Automatic merge from submit-queue daemon/controller.go: refactor worker 1. function name is better to be verb or verb+noun 2. remove unnecessary func call
This commit is contained in:
commit
d1407ecdd3
@ -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{}) {
|
|||||||
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{}) {
|
|||||||
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 {
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
defer dsc.queue.Done(dsKey)
|
|
||||||
err := dsc.syncHandler(dsKey.(string))
|
err := dsc.syncHandler(dsKey.(string))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error syncing daemon set with key %s: %v", dsKey.(string), err)
|
glog.Errorf("Error syncing daemon set with key %s: %v", dsKey.(string), err)
|
||||||
}
|
}
|
||||||
}()
|
dsc.queue.Done(dsKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user