@@ -331,7 +331,7 @@ func (cm *controllerManager) getCluster(ctx context.Context, clusterName string)
331
331
ctx , cancel := context .WithTimeout (ctx , 10 * time .Second )
332
332
defer cancel ()
333
333
var watchErr error
334
- if err := wait .PollImmediateUntilWithContext (ctx , 1 * time .Second , func (ctx context.Context ) (done bool , err error ) {
334
+ if err := wait .PollUntilContextCancel (ctx , 1 * time .Second , true , func (ctx context.Context ) (done bool , err error ) {
335
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.
@@ -350,8 +350,10 @@ func (cm *controllerManager) getCluster(ctx context.Context, clusterName string)
350
350
if err := cm .Add (cl ); err != nil {
351
351
return nil , fmt .Errorf ("cannot add cluster %q to manager: %w" , clusterName , err )
352
352
}
353
+
353
354
// Create a new context for the Cluster, so that it can be stopped independently.
354
355
ctx , cancel := context .WithCancel (context .Background ())
356
+
355
357
c = & engagedCluster {
356
358
Cluster : cl ,
357
359
ctx : ctx ,
@@ -361,8 +363,8 @@ func (cm *controllerManager) getCluster(ctx context.Context, clusterName string)
361
363
return c , nil
362
364
}
363
365
364
- func (cm * controllerManager ) removeLogicalCluster (clusterName string ) error {
365
- // Check if the manager was configured with a logical adapter ,
366
+ func (cm * controllerManager ) removeNamedCluster (clusterName string ) error {
367
+ // Check if the manager was configured with a cluster provider ,
366
368
// otherwise we cannot retrieve the cluster.
367
369
if cm .clusterProvider == nil {
368
370
return fmt .Errorf ("manager was not configured with a cluster provider, cannot retrieve %q" , clusterName )
@@ -596,7 +598,7 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) { //nolint:g
596
598
if clusterListSet .Has (name ) {
597
599
continue
598
600
}
599
- if err := cm .removeLogicalCluster (name ); err != nil {
601
+ if err := cm .removeNamedCluster (name ); err != nil {
600
602
return err
601
603
}
602
604
}
@@ -637,7 +639,7 @@ func (cm *controllerManager) Start(ctx context.Context) (err error) { //nolint:g
637
639
}
638
640
cm .engageClusterAwareRunnables ()
639
641
case watch .Deleted , watch .Error :
640
- if err := cm .removeLogicalCluster (event .ClusterName ); err != nil {
642
+ if err := cm .removeNamedCluster (event .ClusterName ); err != nil {
641
643
return err
642
644
}
643
645
case watch .Bookmark :
0 commit comments