aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-11-09 10:00:46 +0000
committerGravatar GitHub <noreply@github.com> 2016-11-09 10:00:46 +0000
commitda742ed5968abc12417fbae1cfcadc09c0f53186 (patch)
treeec228f4d8177724c1b7f3d72f5010f1cdf19f95c
parent0f8cb5094d04e8b709ad31408cc2e7c961f02093 (diff)
downloadcoredns-da742ed5968abc12417fbae1cfcadc09c0f53186.tar.gz
coredns-da742ed5968abc12417fbae1cfcadc09c0f53186.tar.zst
coredns-da742ed5968abc12417fbae1cfcadc09c0f53186.zip
core: remove unwanted flags (#410)
Remove unwanted flags (mostly from glog) and keep the ones we need.
-rw-r--r--coremain/run.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/coremain/run.go b/coremain/run.go
index f80aa23db..e85159543 100644
--- a/coremain/run.go
+++ b/coremain/run.go
@@ -21,6 +21,20 @@ import (
)
func init() {
+ // Reset flag.CommandLine to get rid of unwanted flags for instance from glog (used in kubernetes).
+ // And readd the once we want to keep.
+ flag.VisitAll(func(f *flag.Flag) {
+ if _, ok := flagsBlacklist[f.Name]; ok {
+ return
+ }
+ flagsToKeep = append(flagsToKeep, f)
+ })
+
+ flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
+ for _, f := range flagsToKeep {
+ flag.Var(f.Value, f.Name, f.Usage)
+ }
+
caddy.TrapSignals()
caddy.DefaultConfigFile = "Corefile"
caddy.Quiet = true // don't show init stuff from caddy
@@ -40,6 +54,7 @@ func init() {
// Run is CoreDNS's main() function.
func Run() {
+
flag.Parse()
caddy.AppName = coreName
@@ -230,3 +245,16 @@ var (
gitShortStat string // git diff-index --shortstat
gitFilesModified string // git diff-index --name-only HEAD
)
+
+// flagsBlacklist removes flags with these names from our flagset.
+var flagsBlacklist = map[string]bool{
+ "logtostderr": true,
+ "alsologtostderr": true,
+ "v": true,
+ "stderrthreshold": true,
+ "vmodule": true,
+ "log_backtrace_at": true,
+ "log_dir": true,
+}
+
+var flagsToKeep []*flag.Flag