Skip to content

Commit

Permalink
Init klog in NewNetworkPolicyController since we don't run main in k3s
Browse files Browse the repository at this point in the history
This allows us to propagate the log verbosity level from k3s to kube-router.

Signed-off-by: Thomas Ferrandiz <[email protected]>
  • Loading branch information
thomasferrandiz committed Apr 6, 2023
1 parent e18008d commit 1fa6a5e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/controllers/netpol/network_policy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto/sha256"
"encoding/base32"
"flag"
"fmt"
"net"
"strconv"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1fa6a5e

Please sign in to comment.