Skip to content

Commit

Permalink
fix(kumactl): set klog to avoid logs from k8s
Browse files Browse the repository at this point in the history
Logs from klog would go to stdout which was ruining the output
of commands like install-control-plane

Fix kumahq#5554

Signed-off-by: Charly Molter <[email protected]>
  • Loading branch information
lahabana committed Jan 6, 2023
1 parent 52bbcd2 commit 94a5b59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/kumactl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/spf13/cobra"
"k8s.io/klog/v2"

"github.com/kumahq/kuma/app/kumactl/cmd/apply"
"github.com/kumahq/kuma/app/kumactl/cmd/completion"
Expand Down Expand Up @@ -44,7 +45,10 @@ func NewRootCmd(root *kumactl_cmd.RootContext) *cobra.Command {
if err != nil {
return err
}
core.SetLogger(core.NewLogger(level))
l := core.NewLogger(level)
core.SetLogger(l)
// Required for any k8s stuff that may log.
klog.SetLogger(l)

// once command line flags have been parsed,
// avoid printing usage instructions
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ require (
k8s.io/apiextensions-apiserver v0.25.4
k8s.io/apimachinery v0.25.4
k8s.io/client-go v0.25.4
k8s.io/klog/v2 v2.80.1
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
sigs.k8s.io/controller-runtime v0.13.1
Expand Down Expand Up @@ -200,7 +201,6 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.4.0 // indirect
k8s.io/component-base v0.25.4 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
Expand Down

0 comments on commit 94a5b59

Please sign in to comment.