Set klog's logtostderr flag (#2529)
* Parse as well as setlogtostderr flag * Enforce setting of logtostderr for klog * Clearup comment on klog
This commit is contained in:
parent
92836cc6f9
commit
39cf482348
1 changed files with 8 additions and 2 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue