From 2ae4ab4b7d99b062a85ffbc1f738a980411d6954 Mon Sep 17 00:00:00 2001 From: Xing Zhou Date: Wed, 7 Dec 2016 15:25:36 +0800 Subject: [PATCH] Added validation for API server's 'apiserver-count' flag. --apiserver-count should be a positive number, otherwise will cause errors when reconciling endpoints in MasterCountEndpointsReconciler. --- cmd/kube-apiserver/app/options/options.go | 2 +- cmd/kube-apiserver/app/options/validation.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/kube-apiserver/app/options/options.go b/cmd/kube-apiserver/app/options/options.go index cbfcd221c68..9f4aed7c266 100644 --- a/cmd/kube-apiserver/app/options/options.go +++ b/cmd/kube-apiserver/app/options/options.go @@ -116,7 +116,7 @@ func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet) { "Currently only applies to long-running requests.") fs.IntVar(&s.MasterCount, "apiserver-count", s.MasterCount, - "The number of apiservers running in the cluster.") + "The number of apiservers running in the cluster, must be a positive number.") // See #14282 for details on how to test/try this option out. // TODO: remove this comment once this option is tested in CI. diff --git a/cmd/kube-apiserver/app/options/validation.go b/cmd/kube-apiserver/app/options/validation.go index 63d5a46d9dd..e2a47f74cbb 100644 --- a/cmd/kube-apiserver/app/options/validation.go +++ b/cmd/kube-apiserver/app/options/validation.go @@ -63,5 +63,8 @@ func (options *ServerRunOptions) Validate() []error { if errs := options.InsecureServing.Validate("insecure-port"); len(errs) > 0 { errors = append(errors, errs...) } + if options.MasterCount <= 0 { + errors = append(errors, fmt.Errorf("--apiserver-count should be a positive number, but value '%d' provided", options.MasterCount)) + } return errors }