diff options
author | 2018-03-09 19:55:43 +0000 | |
---|---|---|
committer | 2018-03-09 19:55:43 +0000 | |
commit | 95342dfaadd6e90cc8924a8c695f012c48d95b8b (patch) | |
tree | f9376bc2a1b5e09d80fd64d060c21b99013305d6 /plugin/kubernetes/setup.go | |
parent | 8d27dd7e924082888f3bb61c4ce768bb28b706e2 (diff) | |
download | coredns-95342dfaadd6e90cc8924a8c695f012c48d95b8b.tar.gz coredns-95342dfaadd6e90cc8924a8c695f012c48d95b8b.tar.zst coredns-95342dfaadd6e90cc8924a8c695f012c48d95b8b.zip |
plugin/kubernetes: make glog log to standard output (#1598)
Jump through all the hoops to make this work.
Diffstat (limited to 'plugin/kubernetes/setup.go')
-rw-r--r-- | plugin/kubernetes/setup.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/plugin/kubernetes/setup.go b/plugin/kubernetes/setup.go index 9eddadbb7..db55ba71f 100644 --- a/plugin/kubernetes/setup.go +++ b/plugin/kubernetes/setup.go @@ -2,7 +2,9 @@ package kubernetes import ( "errors" + "flag" "fmt" + "os" "strconv" "strings" "time" @@ -19,6 +21,13 @@ import ( ) func init() { + // Kubernetes plugin uses the kubernetes library, which uses glog (ugh), we must set 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") + caddy.RegisterPlugin("kubernetes", caddy.Plugin{ ServerType: "dns", Action: setup, @@ -26,6 +35,9 @@ func init() { } func setup(c *caddy.Controller) error { + // See comment in the init function. + os.Stderr = os.Stdout + k, err := kubernetesParse(c) if err != nil { return plugin.Error("kubernetes", err) |