@@ -65,7 +65,7 @@ var _ Runnable = &controllerManager{}
65
65
var _ Manager = & controllerManager {}
66
66
var _ cluster.ByNameGetterFunc = (& controllerManager {}).GetCluster
67
67
68
- type logicalCluster struct {
68
+ type engagedCluster struct {
69
69
cluster.Cluster
70
70
ctx context.Context
71
71
cancel context.CancelFunc
@@ -83,10 +83,10 @@ type controllerManager struct {
83
83
defaultCluster cluster.Cluster
84
84
defaultClusterOptions cluster.Option
85
85
86
- logicalProvider cluster.Provider
86
+ clusterProvider cluster.Provider
87
87
88
88
clusterLock sync.RWMutex // protects clusters
89
- clusters map [string ]* logicalCluster
89
+ clusters map [string ]* engagedCluster
90
90
clusterAwareRunnables []cluster.AwareRunnable
91
91
92
92
// recorderProvider is used to generate event recorders that will be injected into Controllers
@@ -282,8 +282,8 @@ func (cm *controllerManager) engageClusterAwareRunnables() {
282
282
cm .Lock ()
283
283
defer cm .Unlock ()
284
284
285
- // If we don't have a logical adapter , we cannot sync the runnables.
286
- if cm .logicalProvider == nil {
285
+ // If we don't have a cluster provider , we cannot sync the runnables.
286
+ if cm .clusterProvider == nil {
287
287
return
288
288
}
289
289
@@ -299,11 +299,11 @@ func (cm *controllerManager) engageClusterAwareRunnables() {
299
299
}
300
300
}
301
301
302
- func (cm * controllerManager ) getCluster (ctx context.Context , clusterName string ) (c * logicalCluster , err error ) {
303
- // Check if the manager was configured with a logical adapter ,
302
+ func (cm * controllerManager ) getCluster (ctx context.Context , clusterName string ) (c * engagedCluster , err error ) {
303
+ // Check if the manager was configured with a cluster provider ,
304
304
// otherwise we cannot retrieve the cluster.
305
- if cm .logicalProvider == nil {
306
- return nil , fmt .Errorf ("manager was not configured with a logical adapter , cannot retrieve %q" , clusterName )
305
+ if cm .clusterProvider == nil {
306
+ return nil , fmt .Errorf ("manager was not configured with a cluster provider , cannot retrieve %q" , clusterName )
307
307
}
308
308
309
309
// Check if the cluster already exists.
@@ -332,13 +332,13 @@ func (cm *controllerManager) getCluster(ctx context.Context, clusterName string)
332
332
defer cancel ()
333
333
var watchErr error
334
334
if err := wait .PollImmediateUntilWithContext (ctx , 1 * time .Second , func (ctx context.Context ) (done bool , err error ) {
335
- cl , watchErr = cm .logicalProvider .Get (ctx , clusterName , cm .defaultClusterOptions , cluster .WithName (clusterName ))
335
+ cl , watchErr = cm .clusterProvider .Get (ctx , clusterName , cm .defaultClusterOptions , cluster .WithName (clusterName ))
336
336
if watchErr != nil {
337
337
return false , nil //nolint:nilerr // We want to keep trying.
338
338
}
339
339
return true , nil
340
340
}); err != nil {
341
- return nil , fmt .Errorf ("failed create logical cluster %q: %w" , clusterName , kerrors .NewAggregate ([]error {err , watchErr }))
341
+ return nil , fmt .Errorf ("failed create cluster %q: %w" , clusterName , kerrors .NewAggregate ([]error {err , watchErr }))
342
342
}
343
343
}
344
344
@@ -348,11 +348,11 @@ func (cm *controllerManager) getCluster(ctx context.Context, clusterName string)
348
348
// Once added, if the manager has already started, it waits for the Cache to sync before returning
349
349
// otherwise it enqueues the Runnable to be started when the manager starts.
350
350
if err := cm .Add (cl ); err != nil {
351
- return nil , fmt .Errorf ("cannot add logical cluster %q to manager: %w" , clusterName , err )
351
+ return nil , fmt .Errorf ("cannot add cluster %q to manager: %w" , clusterName , err )
352
352
}
353
353
// Create a new context for the Cluster, so that it can be stopped independently.
354
354
ctx , cancel := context .WithCancel (context .Background ())
355
- c = & logicalCluster {
355
+ c = & engagedCluster {
356
356
Cluster : cl ,
357
357
ctx : ctx ,
358
358
cancel : cancel ,
@@ -364,8 +364,8 @@ func (cm *controllerManager) getCluster(ctx context.Context, clusterName string)
364
364
func (cm * controllerManager ) removeLogicalCluster (clusterName string ) error {
365
365
// Check if the manager was configured with a logical adapter,
366
366
// otherwise we cannot retrieve the cluster.
367
- if cm .logicalProvider == nil {
368
- return fmt .Errorf ("manager was not configured with a logical adapter , cannot retrieve %q" , clusterName )
367
+ if cm .clusterProvider == nil {
368
+ return fmt .Errorf ("manager was not configured with a cluster provider , cannot retrieve %q" , clusterName )
369
369
}
370
370
371
371
cm .clusterLock .Lock ()
@@ -578,11 +578,11 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) { //nolint:g
578
578
}()
579
579
}
580
580
581
- // If the manager has been configured with a logical adapter , start it.
582
- if cm .logicalProvider != nil {
581
+ // If the manager has been configured with a cluster provider , start it.
582
+ if cm .clusterProvider != nil {
583
583
if err := cm .add (RunnableFunc (func (ctx context.Context ) error {
584
584
resync := func () error {
585
- clusterList , err := cm .logicalProvider .List ()
585
+ clusterList , err := cm .clusterProvider .List (ctx )
586
586
if err != nil {
587
587
return err
588
588
}
@@ -610,7 +610,7 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) { //nolint:g
610
610
}
611
611
612
612
// Create a watcher and start watching for changes.
613
- watcher , err := cm .logicalProvider .Watch ()
613
+ watcher , err := cm .clusterProvider .Watch ()
614
614
if err != nil {
615
615
return err
616
616
}
@@ -648,7 +648,7 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) { //nolint:g
648
648
}
649
649
}
650
650
})); err != nil {
651
- return fmt .Errorf ("failed to add logical adapter to runnables: %w" , err )
651
+ return fmt .Errorf ("failed to add cluster provider to runnables: %w" , err )
652
652
}
653
653
}
654
654
0 commit comments