in pkg/leadermigration/migrator.go [36:61]
func NewLeaderMigrator(config *internal.LeaderMigrationConfiguration, component string) *LeaderMigrator {
migratedControllers := make(map[string]bool)
for _, leader := range config.ControllerLeaders {
migratedControllers[leader.Name] = leader.Component == component || leader.Component == "*"
}
return &LeaderMigrator{
MigrationReady: make(chan struct{}),
FilterFunc: func(controllerName string) FilterResult {
shouldRun, ok := migratedControllers[controllerName]
if ok {
// The controller is included in the migration
if shouldRun {
// If the controller manager should run the controller,
// start it in the migration lock.
return ControllerMigrated
}
// Otherwise, the controller should be started by
// some other controller manager.
return ControllerUnowned
}
// The controller is not included in the migration,
// and should be started in the main lock.
return ControllerNonMigrated
},
}
}