Skip to content

Revert "Support enabling verbose client-go logging" #2236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 4 additions & 31 deletions cmd/clusters-service/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"crypto/x509/pkix"
"encoding/pem"
"errors"
"flag"
"fmt"
"math/big"
"net"
Expand All @@ -32,7 +31,7 @@ import (
"github.com/go-logr/logr"
grpc_runtime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
gitopsv1alpha1 "github.com/weaveworks/cluster-controller/api/v1alpha1"
"github.com/weaveworks/go-checkpoint"
Expand Down Expand Up @@ -82,7 +81,6 @@ import (
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
k8scache "k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -145,7 +143,6 @@ type Params struct {
CostEstimationFilters string `mapstructure:"cost-estimation-filters"`
CostEstimationAPIRegion string `mapstructure:"cost-estimation-api-region"`
CostEstimationFilename string `mapstructure:"cost-estimation-csv-file"`
KLogVerbosity string `mapstructure:"klog-verbosity"`
}

type OIDCAuthenticationOptions struct {
Expand Down Expand Up @@ -230,13 +227,12 @@ func NewAPIServerCommand(log logr.Logger, tempDir string) *cobra.Command {
cmdFlags.Bool("use-k8s-cached-clients", true, "Enables the use of cached clients")
cmdFlags.String("ui-config", "", "UI configuration, JSON encoded")
cmdFlags.String("pipeline-controller-address", pipelines.DefaultPipelineControllerAddress, "Pipeline controller address")
cmdFlags.String("klog-verbosity", "0", "Set the logging of the klog library")

cmdFlags.String("cost-estimation-filters", "", "Cost estimation filters")
cmdFlags.String("cost-estimation-api-region", "", "API region for cost estimation queries")
cmdFlags.String("cost-estimation-csv-file", "", "Filename to parse as Cost Estimation data")

cmdFlags.VisitAll(func(fl *pflag.Flag) {
cmdFlags.VisitAll(func(fl *flag.Flag) {
if strings.HasPrefix(fl.Name, "cost-estimation") {
cobra.CheckErr(cmdFlags.MarkHidden(fl.Name))
}
Expand Down Expand Up @@ -310,32 +306,9 @@ func initializeConfig(cmd *cobra.Command) error {
return nil
}

// configureKlogVerbosity sets the klog verbosity level.
// This log is used by the client-go k8s libraries and can be useful for debugging
// client-go's network requests.
//
// v=5 - log CRD cache things?
// v=6 - log requests (e.g. GET url)
// v=7 - log req/res headers
// v=8 - log res body
func configureKLogVerbosity(v string) error {
klog.InitFlags(nil)
err := flag.Set("v", v)
if err != nil {
return fmt.Errorf("could not set klog verbosity: %w", err)
}
flag.Parse()
return nil
}

func StartServer(ctx context.Context, log logr.Logger, tempDir string, p Params) error {
featureflags.SetFromEnv(os.Environ())

log.Info("Setting klog verbosity", "verbosity", p.KLogVerbosity)
err := configureKLogVerbosity(p.KLogVerbosity)
if err != nil {
return fmt.Errorf("could not configure klog verbosity: %w", err)
}
featureflags.SetFromEnv(os.Environ())

if p.CAPITemplatesNamespace == "" {
return errors.New("CAPI templates namespace not set")
Expand All @@ -354,7 +327,7 @@ func StartServer(ctx context.Context, log logr.Logger, tempDir string, p Params)
schemeBuilder = append(schemeBuilder, capiv1.AddToScheme)
}

err = schemeBuilder.AddToScheme(scheme)
err := schemeBuilder.AddToScheme(scheme)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ require (
gopkg.in/yaml.v2 v2.4.0
k8s.io/apiserver v0.25.4 // indirect
k8s.io/component-base v0.25.4 // indirect
k8s.io/klog/v2 v2.80.1
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221110221610-a28e98eb7c70 // indirect
k8s.io/kubectl v0.25.4 // indirect
k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 // indirect
Expand Down
3 changes: 0 additions & 3 deletions tools/dev-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ extraEnvVars:
value: ""
- name: WEAVE_GITOPS_FEATURE_TELEMETRY
value: "false"
# Can bump this up to 4+ to get more verbose logging
- name: KLOG_VERBOSITY
value: "0"

extraEnvVarsSecret: ""

Expand Down