diff options
author | 2019-02-07 07:33:31 +0000 | |
---|---|---|
committer | 2019-02-07 07:33:30 +0000 | |
commit | 39cf4823485000fc5d83ac8d2513d6efda93b2e9 (patch) | |
tree | 5b2507b8226471d36fcdb9fde7ec0f5c97dedd95 /plugin/kubernetes/setup.go | |
parent | 92836cc6f9aaf47a349993271ddae273d8e7d25d (diff) | |
download | coredns-39cf4823485000fc5d83ac8d2513d6efda93b2e9.tar.gz coredns-39cf4823485000fc5d83ac8d2513d6efda93b2e9.tar.zst coredns-39cf4823485000fc5d83ac8d2513d6efda93b2e9.zip |
Set klog's logtostderr flag (#2529)
* Parse as well as setlogtostderr flag
* Enforce setting of logtostderr for klog
* Clearup comment on klog
Diffstat (limited to 'plugin/kubernetes/setup.go')
-rw-r--r-- | plugin/kubernetes/setup.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/plugin/kubernetes/setup.go b/plugin/kubernetes/setup.go index faf0f8ca3..ae32a904e 100644 --- a/plugin/kubernetes/setup.go +++ b/plugin/kubernetes/setup.go @@ -20,6 +20,9 @@ import ( "github.com/miekg/dns" meta "k8s.io/apimachinery/pkg/apis/meta/v1" + // Pull this in for logtostderr flag parsing + "k8s.io/klog" + // Excluding azure because it is failing to compile // pull this in here, because we want it excluded if plugin.cfg doesn't have k8s _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" @@ -33,12 +36,15 @@ import ( var log = clog.NewWithPlugin("kubernetes") func init() { - // Kubernetes plugin uses the kubernetes library, which uses glog (ugh), we must set this *flag*, + // Kubernetes plugin uses the kubernetes library, which now uses klog, we must set and parse this flag // so we don't log to the filesystem, which can fill up and crash CoreDNS indirectly by calling os.Exit(). // We also set: os.Stderr = os.Stdout in the setup function below so we output to standard out; as we do for // all CoreDNS logging. We can't do *that* in the init function, because we, when starting, also barf some // things to stderr. - flag.Set("logtostderr", "true") + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + logtostderr := klogFlags.Lookup("logtostderr") + logtostderr.Value.Set("true") caddy.RegisterPlugin("kubernetes", caddy.Plugin{ ServerType: "dns", |