@@ -39,6 +39,7 @@ import (
39
39
"k8s.io/client-go/tools/record"
40
40
cliflag "k8s.io/component-base/cli/flag"
41
41
componentbaseconfig "k8s.io/component-base/config"
42
+ "k8s.io/component-base/metrics"
42
43
"k8s.io/klog"
43
44
kubeschedulerconfigv1alpha2 "k8s.io/kube-scheduler/config/v1alpha2"
44
45
schedulerappconfig "k8s.io/kubernetes/cmd/kube-scheduler/app/config"
@@ -69,6 +70,8 @@ type Options struct {
69
70
WriteConfigTo string
70
71
71
72
Master string
73
+
74
+ ShowHiddenMetricsForVersion string
72
75
}
73
76
74
77
// NewOptions returns default scheduler app options.
@@ -157,6 +160,15 @@ func (o *Options) Flags() (nfs cliflag.NamedFlagSets) {
157
160
leaderelectionconfig .BindFlags (& o .ComponentConfig .LeaderElection .LeaderElectionConfiguration , nfs .FlagSet ("leader election" ))
158
161
utilfeature .DefaultMutableFeatureGate .AddFlag (nfs .FlagSet ("feature gate" ))
159
162
163
+ // TODO(RainbowMango): move it to genericoptions before next flag comes.
164
+ mfs := nfs .FlagSet ("metrics" )
165
+ mfs .StringVar (& o .ShowHiddenMetricsForVersion , "show-hidden-metrics-for-version" , o .ShowHiddenMetricsForVersion ,
166
+ "The previous version for which you want to show hidden metrics. " +
167
+ "Only the previous minor version is meaningful, other values will not be allowed. " +
168
+ "Accepted format of version is <major>.<minor>, e.g.: '1.16'. " +
169
+ "The purpose of this format is make sure you have the opportunity to notice if the next release hides additional metrics, " +
170
+ "rather than being surprised when they are permanently removed in the release after that." )
171
+
160
172
return nfs
161
173
}
162
174
@@ -202,6 +214,9 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
202
214
return err
203
215
}
204
216
}
217
+ if len (o .ShowHiddenMetricsForVersion ) > 0 {
218
+ metrics .SetShowHidden ()
219
+ }
205
220
206
221
return nil
207
222
}
@@ -218,6 +233,7 @@ func (o *Options) Validate() []error {
218
233
errs = append (errs , o .Authentication .Validate ()... )
219
234
errs = append (errs , o .Authorization .Validate ()... )
220
235
errs = append (errs , o .Deprecated .Validate ()... )
236
+ errs = append (errs , metrics .ValidateShowHiddenMetricsVersion (o .ShowHiddenMetricsForVersion )... )
221
237
222
238
return errs
223
239
}
0 commit comments