@@ -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"
@@ -68,6 +69,8 @@ type Options struct {
68
69
WriteConfigTo string
69
70
70
71
Master string
72
+
73
+ ShowHiddenMetricsForVersion string
71
74
}
72
75
73
76
// NewOptions returns default scheduler app options.
@@ -154,6 +157,15 @@ func (o *Options) Flags() (nfs cliflag.NamedFlagSets) {
154
157
leaderelectionconfig .BindFlags (& o .ComponentConfig .LeaderElection .LeaderElectionConfiguration , nfs .FlagSet ("leader election" ))
155
158
utilfeature .DefaultMutableFeatureGate .AddFlag (nfs .FlagSet ("feature gate" ))
156
159
160
+ // TODO(RainbowMango): move it to genericoptions before next flag comes.
161
+ mfs := nfs .FlagSet ("metrics" )
162
+ mfs .StringVar (& o .ShowHiddenMetricsForVersion , "show-hidden-metrics-for-version" , o .ShowHiddenMetricsForVersion ,
163
+ "The previous version for which you want to show hidden metrics. " +
164
+ "Only the previous minor version is meaningful, other values will not be allowed. " +
165
+ "Accepted format of version is <major>.<minor>, e.g.: '1.16'. " +
166
+ "The purpose of this format is make sure you have the opportunity to notice if the next release hides additional metrics, " +
167
+ "rather than being surprised when they are permanently removed in the release after that." )
168
+
157
169
return nfs
158
170
}
159
171
@@ -199,6 +211,9 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
199
211
return err
200
212
}
201
213
}
214
+ if len (o .ShowHiddenMetricsForVersion ) > 0 {
215
+ metrics .SetShowHidden ()
216
+ }
202
217
203
218
return nil
204
219
}
@@ -215,6 +230,7 @@ func (o *Options) Validate() []error {
215
230
errs = append (errs , o .Authentication .Validate ()... )
216
231
errs = append (errs , o .Authorization .Validate ()... )
217
232
errs = append (errs , o .Deprecated .Validate ()... )
233
+ errs = append (errs , metrics .ValidateShowHiddenMetricsVersion (o .ShowHiddenMetricsForVersion )... )
218
234
219
235
return errs
220
236
}
0 commit comments