remove FeatureEnabled in controller-manager/pkg/leadermigration/feature.go

This commit is contained in:
Paco Xu 2022-11-08 11:17:57 +08:00
parent eadb0a29c5
commit a0c139f8d3
3 changed files with 1 additions and 31 deletions

View File

@ -1,26 +0,0 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package leadermigration
import (
_ "k8s.io/controller-manager/pkg/features/register"
)
// FeatureEnabled tells if leader migration is enabled through the feature gate.
func FeatureEnabled() bool {
return true
}

View File

@ -21,7 +21,6 @@ import (
"github.com/spf13/pflag"
"k8s.io/controller-manager/config"
"k8s.io/controller-manager/pkg/leadermigration"
migrationconfig "k8s.io/controller-manager/pkg/leadermigration/config"
)
@ -65,9 +64,6 @@ func (o *LeaderMigrationOptions) ApplyTo(cfg *config.GenericControllerManagerCon
cfg.LeaderMigrationEnabled = false
return nil
}
if o.Enabled && !leadermigration.FeatureEnabled() {
return fmt.Errorf("Leader Migration is not enabled through feature gate")
}
cfg.LeaderMigrationEnabled = o.Enabled
if !cfg.LeaderMigrationEnabled {
return nil

View File

@ -21,5 +21,5 @@ import config "k8s.io/controller-manager/config"
// Enabled checks whether Leader Migration should be enabled, given the GenericControllerManagerConfiguration.
// It considers the feature gate first, and will always return false if the feature gate is not enabled.
func Enabled(genericConfig *config.GenericControllerManagerConfiguration) bool {
return FeatureEnabled() && genericConfig.LeaderElection.LeaderElect && genericConfig.LeaderMigrationEnabled
return genericConfig.LeaderElection.LeaderElect && genericConfig.LeaderMigrationEnabled
}