Skip to content

Commit

Permalink
refine logs for controller watcher (pingcap#1493)
Browse files Browse the repository at this point in the history
  • Loading branch information
aylei authored and sre-bot committed Jan 9, 2020
1 parent 1a524b5 commit 1a203d8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/controller/controller_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/pingcap/tidb-operator/pkg/util"
corev1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -434,12 +435,19 @@ func WatchForController(informer cache.SharedIndexInformer, q workqueue.Interfac
}
refGV, err := schema.ParseGroupVersion(ref.APIVersion)
if err != nil {
utilruntime.HandleError(fmt.Errorf("cannot parse group versio of the controller %v", ref))
utilruntime.HandleError(fmt.Errorf("cannot parse group version for the controller %v of %s/%s",
ref, meta.GetNamespace(), meta.GetName()))
return
}
controllerObj, err := fn(meta.GetNamespace(), ref.Name)
if err != nil {
utilruntime.HandleError(fmt.Errorf("cannot get controller %s/%s", meta.GetNamespace(), ref.Name))
if errors.IsNotFound(err) {
glog.V(4).Infof("controller %s/%s of %s/%s not found, ignore",
meta.GetNamespace(), ref.Name, meta.GetNamespace(), meta.GetName())
} else {
utilruntime.HandleError(fmt.Errorf("cannot get controller %s/%s of %s/%s",
meta.GetNamespace(), ref.Name, meta.GetNamespace(), meta.GetName()))
}
return
}
// Ensure the ref is exactly the controller we listed
Expand Down

0 comments on commit 1a203d8

Please sign in to comment.