提交 cda4f4f0 编写于 作者: M magicsong 提交者: zryfish

🚒 add error message in controller

上级 5a836d9d
...@@ -7,7 +7,7 @@ BIN ?= ks-apiserver ...@@ -7,7 +7,7 @@ BIN ?= ks-apiserver
IMG ?= kubespheredev/ks-apiserver IMG ?= kubespheredev/ks-apiserver
OUTPUT_DIR=bin OUTPUT_DIR=bin
GOFLAGS=-mod=vendor
define ALL_HELP_INFO define ALL_HELP_INFO
# Build code. # Build code.
# #
......
...@@ -2,6 +2,8 @@ package application ...@@ -2,6 +2,8 @@ package application
import ( import (
"fmt" "fmt"
"time"
applicationclient "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned" applicationclient "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned"
applicationinformers "github.com/kubernetes-sigs/application/pkg/client/informers/externalversions/app/v1beta1" applicationinformers "github.com/kubernetes-sigs/application/pkg/client/informers/externalversions/app/v1beta1"
applicationlister "github.com/kubernetes-sigs/application/pkg/client/listers/app/v1beta1" applicationlister "github.com/kubernetes-sigs/application/pkg/client/listers/app/v1beta1"
...@@ -25,7 +27,6 @@ import ( ...@@ -25,7 +27,6 @@ import (
servicemeshlisters "kubesphere.io/kubesphere/pkg/client/listers/servicemesh/v1alpha2" servicemeshlisters "kubesphere.io/kubesphere/pkg/client/listers/servicemesh/v1alpha2"
"kubesphere.io/kubesphere/pkg/controller/virtualservice/util" "kubesphere.io/kubesphere/pkg/controller/virtualservice/util"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
"time"
) )
const ( const (
...@@ -148,11 +149,10 @@ func NewApplicationController(serviceInformer coreinformers.ServiceInformer, ...@@ -148,11 +149,10 @@ func NewApplicationController(serviceInformer coreinformers.ServiceInformer,
} }
func (v *ApplicationController) Start(stopCh <-chan struct{}) error { func (v *ApplicationController) Start(stopCh <-chan struct{}) error {
v.Run(2, stopCh) return v.Run(2, stopCh)
return nil
} }
func (v *ApplicationController) Run(workers int, stopCh <-chan struct{}) { func (v *ApplicationController) Run(workers int, stopCh <-chan struct{}) error {
defer utilruntime.HandleCrash() defer utilruntime.HandleCrash()
defer v.queue.ShutDown() defer v.queue.ShutDown()
...@@ -160,14 +160,14 @@ func (v *ApplicationController) Run(workers int, stopCh <-chan struct{}) { ...@@ -160,14 +160,14 @@ func (v *ApplicationController) Run(workers int, stopCh <-chan struct{}) {
defer log.Info("shutting down application controller") defer log.Info("shutting down application controller")
if !cache.WaitForCacheSync(stopCh, v.deploymentSynced, v.statefulSetSynced, v.serviceSynced, v.strategySynced, v.servicePolicySynced, v.applicationSynced) { if !cache.WaitForCacheSync(stopCh, v.deploymentSynced, v.statefulSetSynced, v.serviceSynced, v.strategySynced, v.servicePolicySynced, v.applicationSynced) {
return return fmt.Errorf("failed to wait for caches to sync")
} }
for i := 0; i < workers; i++ { for i := 0; i < workers; i++ {
go wait.Until(v.worker, v.workerLoopPeriod, stopCh) go wait.Until(v.worker, v.workerLoopPeriod, stopCh)
} }
<-stopCh <-stopCh
return nil
} }
func (v *ApplicationController) worker() { func (v *ApplicationController) worker() {
......
...@@ -148,12 +148,10 @@ func NewDestinationRuleController(deploymentInformer informersv1.DeploymentInfor ...@@ -148,12 +148,10 @@ func NewDestinationRuleController(deploymentInformer informersv1.DeploymentInfor
} }
func (v *DestinationRuleController) Start(stopCh <-chan struct{}) error { func (v *DestinationRuleController) Start(stopCh <-chan struct{}) error {
v.Run(5, stopCh) return v.Run(5, stopCh)
return nil
} }
func (v *DestinationRuleController) Run(workers int, stopCh <-chan struct{}) { func (v *DestinationRuleController) Run(workers int, stopCh <-chan struct{}) error {
defer utilruntime.HandleCrash() defer utilruntime.HandleCrash()
defer v.queue.ShutDown() defer v.queue.ShutDown()
...@@ -161,7 +159,7 @@ func (v *DestinationRuleController) Run(workers int, stopCh <-chan struct{}) { ...@@ -161,7 +159,7 @@ func (v *DestinationRuleController) Run(workers int, stopCh <-chan struct{}) {
defer log.Info("shutting down destinationrule controller") defer log.Info("shutting down destinationrule controller")
if !cache.WaitForCacheSync(stopCh, v.serviceSynced, v.destinationRuleSynced, v.deploymentSynced, v.servicePolicySynced) { if !cache.WaitForCacheSync(stopCh, v.serviceSynced, v.destinationRuleSynced, v.deploymentSynced, v.servicePolicySynced) {
return return fmt.Errorf("failed to wait for caches to sync")
} }
for i := 0; i < workers; i++ { for i := 0; i < workers; i++ {
...@@ -169,6 +167,7 @@ func (v *DestinationRuleController) Run(workers int, stopCh <-chan struct{}) { ...@@ -169,6 +167,7 @@ func (v *DestinationRuleController) Run(workers int, stopCh <-chan struct{}) {
} }
<-stopCh <-stopCh
return nil
} }
func (v *DestinationRuleController) enqueueService(obj interface{}) { func (v *DestinationRuleController) enqueueService(obj interface{}) {
......
...@@ -95,12 +95,10 @@ func NewJobController(jobInformer batchv1informers.JobInformer, client clientset ...@@ -95,12 +95,10 @@ func NewJobController(jobInformer batchv1informers.JobInformer, client clientset
} }
func (v *JobController) Start(stopCh <-chan struct{}) error { func (v *JobController) Start(stopCh <-chan struct{}) error {
v.Run(5, stopCh) return v.Run(5, stopCh)
return nil
} }
func (v *JobController) Run(workers int, stopCh <-chan struct{}) { func (v *JobController) Run(workers int, stopCh <-chan struct{}) error {
defer utilruntime.HandleCrash() defer utilruntime.HandleCrash()
defer v.queue.ShutDown() defer v.queue.ShutDown()
...@@ -108,7 +106,7 @@ func (v *JobController) Run(workers int, stopCh <-chan struct{}) { ...@@ -108,7 +106,7 @@ func (v *JobController) Run(workers int, stopCh <-chan struct{}) {
defer log.Info("shutting down job controller") defer log.Info("shutting down job controller")
if !cache.WaitForCacheSync(stopCh, v.jobSynced) { if !cache.WaitForCacheSync(stopCh, v.jobSynced) {
return return fmt.Errorf("failed to wait for caches to sync")
} }
for i := 0; i < workers; i++ { for i := 0; i < workers; i++ {
...@@ -116,6 +114,7 @@ func (v *JobController) Run(workers int, stopCh <-chan struct{}) { ...@@ -116,6 +114,7 @@ func (v *JobController) Run(workers int, stopCh <-chan struct{}) {
} }
<-stopCh <-stopCh
return nil
} }
func (v *JobController) enqueueJob(obj interface{}) { func (v *JobController) enqueueJob(obj interface{}) {
......
...@@ -145,11 +145,10 @@ func NewVirtualServiceController(serviceInformer coreinformers.ServiceInformer, ...@@ -145,11 +145,10 @@ func NewVirtualServiceController(serviceInformer coreinformers.ServiceInformer,
} }
func (v *VirtualServiceController) Start(stopCh <-chan struct{}) error { func (v *VirtualServiceController) Start(stopCh <-chan struct{}) error {
v.Run(5, stopCh) return v.Run(5, stopCh)
return nil
} }
func (v *VirtualServiceController) Run(workers int, stopCh <-chan struct{}) { func (v *VirtualServiceController) Run(workers int, stopCh <-chan struct{}) error {
defer utilruntime.HandleCrash() defer utilruntime.HandleCrash()
defer v.queue.ShutDown() defer v.queue.ShutDown()
...@@ -157,7 +156,7 @@ func (v *VirtualServiceController) Run(workers int, stopCh <-chan struct{}) { ...@@ -157,7 +156,7 @@ func (v *VirtualServiceController) Run(workers int, stopCh <-chan struct{}) {
defer log.Info("shutting down virtualservice controller") defer log.Info("shutting down virtualservice controller")
if !cache.WaitForCacheSync(stopCh, v.serviceSynced, v.virtualServiceSynced, v.destinationRuleSynced, v.strategySynced) { if !cache.WaitForCacheSync(stopCh, v.serviceSynced, v.virtualServiceSynced, v.destinationRuleSynced, v.strategySynced) {
return return fmt.Errorf("failed to wait for caches to sync")
} }
for i := 0; i < workers; i++ { for i := 0; i < workers; i++ {
...@@ -165,6 +164,7 @@ func (v *VirtualServiceController) Run(workers int, stopCh <-chan struct{}) { ...@@ -165,6 +164,7 @@ func (v *VirtualServiceController) Run(workers int, stopCh <-chan struct{}) {
} }
<-stopCh <-stopCh
return nil
} }
func (v *VirtualServiceController) enqueueService(obj interface{}) { func (v *VirtualServiceController) enqueueService(obj interface{}) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册