From 1fa6a5eac66caf8c44bb6e302cfe37d41e994a70 Mon Sep 17 00:00:00 2001 From: Thomas Ferrandiz Date: Tue, 4 Apr 2023 13:23:02 +0000 Subject: [PATCH] Init klog in NewNetworkPolicyController since we don't run main in k3s This allows us to propagate the log verbosity level from k3s to kube-router. Signed-off-by: Thomas Ferrandiz --- pkg/controllers/netpol/network_policy_controller.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/controllers/netpol/network_policy_controller.go b/pkg/controllers/netpol/network_policy_controller.go index d786e0681..2a8cec270 100644 --- a/pkg/controllers/netpol/network_policy_controller.go +++ b/pkg/controllers/netpol/network_policy_controller.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/sha256" "encoding/base32" + "flag" "fmt" "net" "strconv" @@ -735,6 +736,13 @@ func NewNetworkPolicyController(clientset kubernetes.Interface, ipSetHandlers map[v1core.IPFamily]utils.IPSetHandler) (*NetworkPolicyController, error) { npc := NetworkPolicyController{ipsetMutex: ipsetMutex} + // init klog here since we don't run kube-router main in k3s + klog.InitFlags(nil) + err := flag.Set("v", config.VLevel) + if err != nil { + klog.Errorf("failed to set flag: %s", err) + } + // Creating a single-item buffered channel to ensure that we only keep a single full sync request at a time, // additional requests would be pointless to queue since after the first one was processed the system would already // be up to date with all of the policy changes from any enqueued request after that