plugin/kubernetes: remove some of the klog setup (#3054)

I don't believe this is actually needed (anymore). The:

os.Stderr = os.Stdout

is a crazy hack that def. needs to go.

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben 2019-07-30 16:35:07 +00:00 committed by GitHub
parent 6cea8869cf
commit 4fda9535d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,6 @@ package kubernetes
import ( import (
"errors" "errors"
"flag"
"fmt" "fmt"
"os" "os"
"strconv" "strconv"
@ -36,15 +35,7 @@ import (
var log = clog.NewWithPlugin("kubernetes") var log = clog.NewWithPlugin("kubernetes")
func init() { func init() {
// Kubernetes plugin uses the kubernetes library, which now uses klog, we must set and parse this flag klog.SetOutput(os.Stdout)
// 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.
klogFlags := flag.NewFlagSet("klog", flag.ExitOnError)
klog.InitFlags(klogFlags)
logtostderr := klogFlags.Lookup("logtostderr")
logtostderr.Value.Set("true")
caddy.RegisterPlugin("kubernetes", caddy.Plugin{ caddy.RegisterPlugin("kubernetes", caddy.Plugin{
ServerType: "dns", ServerType: "dns",
@ -53,9 +44,6 @@ func init() {
} }
func setup(c *caddy.Controller) error { func setup(c *caddy.Controller) error {
// See comment in the init function.
os.Stderr = os.Stdout
k, err := kubernetesParse(c) k, err := kubernetesParse(c)
if err != nil { if err != nil {
return plugin.Error("kubernetes", err) return plugin.Error("kubernetes", err)