mirror of https://github.com/k3s-io/k3s
Update non-test code to use DefaultMutableFeatureGate
parent
1d6db5924f
commit
d440ecdd3b
|
@ -143,7 +143,7 @@ func (o *CloudControllerManagerOptions) Flags() apiserverflag.NamedFlagSets {
|
||||||
fs.StringVar(&o.Kubeconfig, "kubeconfig", o.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
|
fs.StringVar(&o.Kubeconfig, "kubeconfig", o.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
|
||||||
fs.DurationVar(&o.NodeStatusUpdateFrequency.Duration, "node-status-update-frequency", o.NodeStatusUpdateFrequency.Duration, "Specifies how often the controller updates nodes' status.")
|
fs.DurationVar(&o.NodeStatusUpdateFrequency.Duration, "node-status-update-frequency", o.NodeStatusUpdateFrequency.Duration, "Specifies how often the controller updates nodes' status.")
|
||||||
|
|
||||||
utilfeature.DefaultFeatureGate.AddFlag(fss.FlagSet("generic"))
|
utilfeature.DefaultMutableFeatureGate.AddFlag(fss.FlagSet("generic"))
|
||||||
|
|
||||||
return fss
|
return fss
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,7 +261,7 @@ func (s *KubeControllerManagerOptions) Flags(allControllers []string, disabledBy
|
||||||
fs := fss.FlagSet("misc")
|
fs := fss.FlagSet("misc")
|
||||||
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig).")
|
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig).")
|
||||||
fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
|
fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
|
||||||
utilfeature.DefaultFeatureGate.AddFlag(fss.FlagSet("generic"))
|
utilfeature.DefaultMutableFeatureGate.AddFlag(fss.FlagSet("generic"))
|
||||||
|
|
||||||
return fss
|
return fss
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ func (o *Options) Complete() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utilfeature.DefaultFeatureGate.SetFromMap(o.config.FeatureGates); err != nil {
|
if err := utilfeature.DefaultMutableFeatureGate.SetFromMap(o.config.FeatureGates); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ func (o *Options) Flags() (nfs apiserverflag.NamedFlagSets) {
|
||||||
o.Deprecated.AddFlags(nfs.FlagSet("deprecated"), &o.ComponentConfig)
|
o.Deprecated.AddFlags(nfs.FlagSet("deprecated"), &o.ComponentConfig)
|
||||||
|
|
||||||
leaderelectionconfig.BindFlags(&o.ComponentConfig.LeaderElection.LeaderElectionConfiguration, nfs.FlagSet("leader election"))
|
leaderelectionconfig.BindFlags(&o.ComponentConfig.LeaderElection.LeaderElectionConfiguration, nfs.FlagSet("leader election"))
|
||||||
utilfeature.DefaultFeatureGate.AddFlag(nfs.FlagSet("feature gate"))
|
utilfeature.DefaultMutableFeatureGate.AddFlag(nfs.FlagSet("feature gate"))
|
||||||
|
|
||||||
return nfs
|
return nfs
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API
|
||||||
utilflag.PrintFlags(cleanFlagSet)
|
utilflag.PrintFlags(cleanFlagSet)
|
||||||
|
|
||||||
// set feature gates from initial flags-based config
|
// set feature gates from initial flags-based config
|
||||||
if err := utilfeature.DefaultFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil {
|
if err := utilfeature.DefaultMutableFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil {
|
||||||
klog.Fatal(err)
|
klog.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API
|
||||||
klog.Fatal(err)
|
klog.Fatal(err)
|
||||||
}
|
}
|
||||||
// update feature gates based on new config
|
// update feature gates based on new config
|
||||||
if err := utilfeature.DefaultFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil {
|
if err := utilfeature.DefaultMutableFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil {
|
||||||
klog.Fatal(err)
|
klog.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API
|
||||||
kubeletConfig = dynamicKubeletConfig
|
kubeletConfig = dynamicKubeletConfig
|
||||||
// Note: flag precedence was already enforced in the controller, prior to validation,
|
// Note: flag precedence was already enforced in the controller, prior to validation,
|
||||||
// by our above transform function. Now we simply update feature gates from the new config.
|
// by our above transform function. Now we simply update feature gates from the new config.
|
||||||
if err := utilfeature.DefaultFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil {
|
if err := utilfeature.DefaultMutableFeatureGate.SetFromMap(kubeletConfig.FeatureGates); err != nil {
|
||||||
klog.Fatal(err)
|
klog.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ func makeEventRecorder(kubeDeps *kubelet.Dependencies, nodeName types.NodeName)
|
||||||
|
|
||||||
func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, stopCh <-chan struct{}) (err error) {
|
func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies, stopCh <-chan struct{}) (err error) {
|
||||||
// Set global feature gates based on the value on the initial KubeletServer
|
// Set global feature gates based on the value on the initial KubeletServer
|
||||||
err = utilfeature.DefaultFeatureGate.SetFromMap(s.KubeletConfiguration.FeatureGates)
|
err = utilfeature.DefaultMutableFeatureGate.SetFromMap(s.KubeletConfiguration.FeatureGates)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,7 +396,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
utilfeature.DefaultFeatureGate.Add(defaultKubernetesFeatureGates)
|
utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates)
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultKubernetesFeatureGates consists of all known Kubernetes-specific feature keys.
|
// defaultKubernetesFeatureGates consists of all known Kubernetes-specific feature keys.
|
||||||
|
|
|
@ -49,7 +49,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
utilfeature.DefaultFeatureGate.Add(defaultKubernetesFeatureGates)
|
utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates)
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultKubernetesFeatureGates consists of all known Kubernetes-specific feature keys.
|
// defaultKubernetesFeatureGates consists of all known Kubernetes-specific feature keys.
|
||||||
|
|
|
@ -85,7 +85,7 @@ func (i *initializer) ValidateInitialization() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.Initializers) {
|
if !utilfeature.DefaultFeatureGate.Enabled(features.Initializers) {
|
||||||
if err := utilfeature.DefaultFeatureGate.Set(string(features.Initializers) + "=true"); err != nil {
|
if err := utilfeature.DefaultMutableFeatureGate.Set(string(features.Initializers) + "=true"); err != nil {
|
||||||
klog.Errorf("error enabling Initializers feature as part of admission plugin setup: %v", err)
|
klog.Errorf("error enabling Initializers feature as part of admission plugin setup: %v", err)
|
||||||
} else {
|
} else {
|
||||||
klog.Infof("enabled Initializers feature as part of admission plugin setup")
|
klog.Infof("enabled Initializers feature as part of admission plugin setup")
|
||||||
|
|
|
@ -91,7 +91,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
utilfeature.DefaultFeatureGate.Add(defaultKubernetesFeatureGates)
|
utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates)
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultKubernetesFeatureGates consists of all known Kubernetes-specific feature keys.
|
// defaultKubernetesFeatureGates consists of all known Kubernetes-specific feature keys.
|
||||||
|
|
|
@ -154,5 +154,5 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
|
||||||
"handler, which picks a randomized value above this number as the connection timeout, "+
|
"handler, which picks a randomized value above this number as the connection timeout, "+
|
||||||
"to spread out load.")
|
"to spread out load.")
|
||||||
|
|
||||||
utilfeature.DefaultFeatureGate.AddFlag(fs)
|
utilfeature.DefaultMutableFeatureGate.AddFlag(fs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ func (e *E2EServices) startKubelet() (*server, error) {
|
||||||
klog.Info("Starting kubelet")
|
klog.Info("Starting kubelet")
|
||||||
|
|
||||||
// set feature gates so we can check which features are enabled and pass the appropriate flags
|
// set feature gates so we can check which features are enabled and pass the appropriate flags
|
||||||
utilfeature.DefaultFeatureGate.SetFromMap(framework.TestContext.FeatureGates)
|
utilfeature.DefaultMutableFeatureGate.SetFromMap(framework.TestContext.FeatureGates)
|
||||||
|
|
||||||
// Build kubeconfig
|
// Build kubeconfig
|
||||||
kubeconfigPath, err := createKubeconfigCWD()
|
kubeconfigPath, err := createKubeconfigCWD()
|
||||||
|
|
|
@ -109,7 +109,7 @@ func (e *E2EServices) Stop() {
|
||||||
func RunE2EServices(t *testing.T) {
|
func RunE2EServices(t *testing.T) {
|
||||||
// Populate global DefaultFeatureGate with value from TestContext.FeatureGates.
|
// Populate global DefaultFeatureGate with value from TestContext.FeatureGates.
|
||||||
// This way, statically-linked components see the same feature gate config as the test context.
|
// This way, statically-linked components see the same feature gate config as the test context.
|
||||||
utilfeature.DefaultFeatureGate.SetFromMap(framework.TestContext.FeatureGates)
|
utilfeature.DefaultMutableFeatureGate.SetFromMap(framework.TestContext.FeatureGates)
|
||||||
e := newE2EServices()
|
e := newE2EServices()
|
||||||
if err := e.run(t); err != nil {
|
if err := e.run(t); err != nil {
|
||||||
klog.Fatalf("Failed to run e2e services: %v", err)
|
klog.Fatalf("Failed to run e2e services: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue