allow enabling Leader Migration without config flag.

This commit is contained in:
Indeed 2021-06-08 15:22:11 -07:00
parent bade96ed78
commit 6ba7b3d26b
2 changed files with 6 additions and 3 deletions

View File

@ -73,7 +73,8 @@ func (o *LeaderMigrationOptions) ApplyTo(cfg *config.GenericControllerManagerCon
return nil
}
if o.ControllerMigrationConfig == "" {
return fmt.Errorf("--leader-migration-config is required")
cfg.LeaderMigration = *migrationconfig.DefaultLeaderMigrationConfiguration()
return nil
}
leaderMigrationConfig, err := migrationconfig.ReadLeaderMigrationConfiguration(o.ControllerMigrationConfig)
if err != nil {

View File

@ -27,6 +27,7 @@ import (
featuregatetesting "k8s.io/component-base/featuregate/testing"
"k8s.io/controller-manager/config"
"k8s.io/controller-manager/pkg/features"
migrationconfig "k8s.io/controller-manager/pkg/leadermigration/config"
)
func TestLeaderMigrationOptions(t *testing.T) {
@ -53,11 +54,12 @@ func TestLeaderMigrationOptions(t *testing.T) {
expectErr: true,
},
{
name: "enabled, but missing configuration file",
name: "enabled, with default configuration",
flags: []string{"--enable-leader-migration"},
enableFeatureGate: true,
expectEnabled: true,
expectErr: true,
expectErr: false,
expectConfig: migrationconfig.DefaultLeaderMigrationConfiguration(),
},
{
name: "enabled, with custom configuration file",