From 37c65102907429478cbdb4552cba35796f91fedf Mon Sep 17 00:00:00 2001 From: xiangpengzhao Date: Thu, 11 Jan 2018 16:55:19 +0800 Subject: [PATCH] Make command-line flag --feature-gates compatible --- cmd/kube-proxy/app/server.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/kube-proxy/app/server.go b/cmd/kube-proxy/app/server.go index 5076bf9bc64..72a8957e359 100644 --- a/cmd/kube-proxy/app/server.go +++ b/cmd/kube-proxy/app/server.go @@ -39,6 +39,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apiserver/pkg/server/healthz" utilfeature "k8s.io/apiserver/pkg/util/feature" + "k8s.io/apiserver/pkg/util/flag" clientgoclientset "k8s.io/client-go/kubernetes" v1core "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/rest" @@ -166,7 +167,8 @@ func AddFlags(options *Options, fs *pflag.FlagSet) { "NAT timeout for TCP connections in the CLOSE_WAIT state") fs.BoolVar(&options.config.EnableProfiling, "profiling", options.config.EnableProfiling, "If true enables profiling via web interface on /debug/pprof handler.") fs.StringVar(&options.config.IPVS.Scheduler, "ipvs-scheduler", options.config.IPVS.Scheduler, "The ipvs scheduler type when proxy mode is ipvs") - utilfeature.DefaultFeatureGate.AddFlag(fs) + fs.Var(flag.NewMapStringBool(&options.config.FeatureGates), "feature-gates", "A set of key=value pairs that describe feature gates for alpha/experimental features. "+ + "Options are:\n"+strings.Join(utilfeature.DefaultFeatureGate.KnownFeatures(), "\n")) } func NewOptions() *Options { @@ -192,11 +194,14 @@ func (o *Options) Complete() error { return err } else { o.config = c - // Make sure we apply the feature gate settings in the config file. - utilfeature.DefaultFeatureGate.SetFromMap(o.config.FeatureGates) } } + err := utilfeature.DefaultFeatureGate.SetFromMap(o.config.FeatureGates) + if err != nil { + return err + } + return nil }