From 657470c8f27de71451c81639e64d148b56354829 Mon Sep 17 00:00:00 2001 From: Yan Zhu Date: Sun, 28 Apr 2019 17:30:27 +0800 Subject: [PATCH] Fix klog cant use V module The side affect of this commit is glog's V module not work. --- pkg/controller/config.go | 4 ++++ pkg/controller/endpoint.go | 4 ++-- pkg/controller/namespace.go | 6 +++--- pkg/controller/node.go | 4 ++-- pkg/controller/pod.go | 6 +++--- pkg/controller/service.go | 4 ++-- pkg/daemon/config.go | 3 +++ pkg/daemon/gateway.go | 6 +++--- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/pkg/controller/config.go b/pkg/controller/config.go index babf162182d..7552567b83d 100644 --- a/pkg/controller/config.go +++ b/pkg/controller/config.go @@ -60,6 +60,8 @@ func ParseFlags() (*Configuration, error) { argClusterUdpLoadBalancer = pflag.String("cluster-udp-loadbalancer", "cluster-udp-loadbalancer", "The name for cluster udp loadbalancer") ) + flag.Set("alsologtostderr", "true") + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) klog.InitFlags(klogFlags) @@ -72,8 +74,10 @@ func ParseFlags() (*Configuration, error) { } }) + pflag.CommandLine.AddGoFlagSet(klogFlags) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) pflag.Parse() + config := &Configuration{ OvnNbSocket: *argOvnNbSocket, OvnNbHost: *argOvnNbHost, diff --git a/pkg/controller/endpoint.go b/pkg/controller/endpoint.go index 0ecc647a173..2f5656daa31 100644 --- a/pkg/controller/endpoint.go +++ b/pkg/controller/endpoint.go @@ -21,7 +21,7 @@ func (c *Controller) enqueueAddEndpoint(obj interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue add endpoint %s", key) + klog.V(3).Infof("enqueue add endpoint %s", key) c.updateEndpointQueue.AddRateLimited(key) } @@ -45,7 +45,7 @@ func (c *Controller) enqueueUpdateEndpoint(old, new interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue update endpoint %s", key) + klog.V(3).Infof("enqueue update endpoint %s", key) c.updateEndpointQueue.AddRateLimited(key) } diff --git a/pkg/controller/namespace.go b/pkg/controller/namespace.go index 35d81cee650..7066aab82e7 100644 --- a/pkg/controller/namespace.go +++ b/pkg/controller/namespace.go @@ -23,7 +23,7 @@ func (c *Controller) enqueueAddNamespace(obj interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue add namespace %s", key) + klog.V(3).Infof("enqueue add namespace %s", key) c.addNamespaceQueue.AddRateLimited(key) } @@ -37,7 +37,7 @@ func (c *Controller) enqueueDeleteNamespace(obj interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue delete namespace %s", key) + klog.V(3).Infof("enqueue delete namespace %s", key) c.deleteNamespaceQueue.AddRateLimited(key) } @@ -58,7 +58,7 @@ func (c *Controller) enqueueUpdateNamespace(old, new interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue update namespace %s", key) + klog.V(3).Infof("enqueue update namespace %s", key) c.updateNamespaceQueue.AddRateLimited(key) } } diff --git a/pkg/controller/node.go b/pkg/controller/node.go index b517f66015f..35ef732dc58 100644 --- a/pkg/controller/node.go +++ b/pkg/controller/node.go @@ -25,7 +25,7 @@ func (c *Controller) enqueueAddNode(obj interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue add node %s", key) + klog.V(3).Infof("enqueue add node %s", key) c.addNodeQueue.AddRateLimited(key) } @@ -39,7 +39,7 @@ func (c *Controller) enqueueDeleteNode(obj interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue delete node %s", key) + klog.V(3).Infof("enqueue delete node %s", key) c.deleteNodeQueue.AddRateLimited(key) } diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index 066b4badf59..89a9df8e5e5 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -30,7 +30,7 @@ func (c *Controller) enqueueAddPod(obj interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue add pod %s", key) + klog.V(3).Infof("enqueue add pod %s", key) c.addPodQueue.AddRateLimited(key) } @@ -44,7 +44,7 @@ func (c *Controller) enqueueDeletePod(obj interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue delete pod %s", key) + klog.V(3).Infof("enqueue delete pod %s", key) c.deletePodQueue.AddRateLimited(key) } @@ -65,7 +65,7 @@ func (c *Controller) enqueueUpdatePod(oldObj, newObj interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue update pod %s", key) + klog.V(3).Infof("enqueue update pod %s", key) c.updatePodQueue.AddRateLimited(key) } } diff --git a/pkg/controller/service.go b/pkg/controller/service.go index a4d683fe9cb..41d16bf6169 100644 --- a/pkg/controller/service.go +++ b/pkg/controller/service.go @@ -22,7 +22,7 @@ func (c *Controller) enqueueAddService(obj interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue add service %s", key) + klog.V(3).Infof("enqueue add service %s", key) c.addServiceQueue.AddRateLimited(key) } @@ -42,7 +42,7 @@ func (c *Controller) enqueueUpdateService(old, new interface{}) { utilruntime.HandleError(err) return } - klog.V(5).Infof("enqueue update service %s", key) + klog.V(3).Infof("enqueue update service %s", key) c.updateServiceQueue.AddRateLimited(key) } diff --git a/pkg/daemon/config.go b/pkg/daemon/config.go index 6d1606beacd..fa4dee5ea6d 100644 --- a/pkg/daemon/config.go +++ b/pkg/daemon/config.go @@ -32,6 +32,8 @@ func ParseFlags() (*Configuration, error) { argServiceClusterIPRange = pflag.String("service-cluster-ip-range", "10.96.0.0/12", "The kubernetes service cluster ip range") ) + flag.Set("alsologtostderr", "true") + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) klog.InitFlags(klogFlags) @@ -44,6 +46,7 @@ func ParseFlags() (*Configuration, error) { } }) + pflag.CommandLine.AddGoFlagSet(klogFlags) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) pflag.Parse() diff --git a/pkg/daemon/gateway.go b/pkg/daemon/gateway.go index 8198b423f84..51f7ac5955e 100644 --- a/pkg/daemon/gateway.go +++ b/pkg/daemon/gateway.go @@ -83,7 +83,7 @@ LOOP: klog.Info("exit gateway") break LOOP case <-ticker.C: - klog.V(5).Info("tick") + klog.V(3).Info("tick") } subnets, err := c.getSubnets() if err != nil { @@ -141,7 +141,7 @@ func (c *Controller) getLocalPodIPsNeedNAT() ([]string, error) { } } } - klog.V(5).Infof("local pod ips %v", localPodIPs) + klog.V(3).Infof("local pod ips %v", localPodIPs) return localPodIPs, nil } @@ -157,6 +157,6 @@ func (c *Controller) getSubnets() ([]string, error) { subnets = append(subnets, subnet) } } - klog.V(5).Infof("subnets %v", subnets) + klog.V(3).Infof("subnets %v", subnets) return subnets, nil }