@@ -20,6 +20,7 @@ import (
20
20
"context"
21
21
"fmt"
22
22
"path"
23
+ "strings"
23
24
"sync"
24
25
"time"
25
26
@@ -209,7 +210,7 @@ func (r *ClusterReconciler) reconcileDelete(ctx context.Context, cluster *cluste
209
210
if cluster .Spec .ControlPlaneRef != nil {
210
211
obj , err := external .Get (ctx , r .Client , cluster .Spec .ControlPlaneRef , cluster .Namespace )
211
212
switch {
212
- case apierrors .IsNotFound (err ):
213
+ case apierrors .IsNotFound (errors . Cause ( err ) ):
213
214
case err != nil :
214
215
return reconcile.Result {}, err
215
216
case obj .GetDeletionTimestamp ().IsZero ():
@@ -267,7 +268,7 @@ func (r *ClusterReconciler) reconcileDelete(ctx context.Context, cluster *cluste
267
268
268
269
if descendantCount := descendants .length (); descendantCount > 0 {
269
270
indirect := descendantCount - len (children )
270
- logger .Info ("Cluster still has descendants - need to requeue" , "direct " , len ( children ), "indirect" , indirect )
271
+ logger .Info ("Cluster still has descendants - need to requeue" , "descendants " , descendants . descendantNames ( ), "indirect descendants count " , indirect )
271
272
// Requeue so we can check the next time to see if there are still any descendants left.
272
273
return ctrl.Result {RequeueAfter : deleteRequeueAfter }, nil
273
274
}
@@ -314,6 +315,39 @@ func (c *clusterDescendants) length() int {
314
315
len (c .workerMachines .Items )
315
316
}
316
317
318
+ func (c * clusterDescendants ) descendantNames () string {
319
+ descendants := make ([]string , 0 )
320
+ controlPlaneMachineNames := make ([]string , len (c .controlPlaneMachines .Items ))
321
+ for i , controlPlaneMachine := range c .controlPlaneMachines .Items {
322
+ controlPlaneMachineNames [i ] = controlPlaneMachine .Name
323
+ }
324
+ if len (controlPlaneMachineNames ) > 0 {
325
+ descendants = append (descendants , "Control plane machines: " + strings .Join (controlPlaneMachineNames , "," ))
326
+ }
327
+ machineDeploymentNames := make ([]string , len (c .machineDeployments .Items ))
328
+ for i , machineDeployment := range c .machineDeployments .Items {
329
+ machineDeploymentNames [i ] = machineDeployment .Name
330
+ }
331
+ if len (machineDeploymentNames ) > 0 {
332
+ descendants = append (descendants , "Machine deployments: " + strings .Join (machineDeploymentNames , "," ))
333
+ }
334
+ machineSetNames := make ([]string , len (c .machineSets .Items ))
335
+ for i , machineSet := range c .machineSets .Items {
336
+ machineSetNames [i ] = machineSet .Name
337
+ }
338
+ if len (machineSetNames ) > 0 {
339
+ descendants = append (descendants , "Machine sets: " + strings .Join (machineSetNames , "," ))
340
+ }
341
+ workerMachineNames := make ([]string , len (c .workerMachines .Items ))
342
+ for i , workerMachine := range c .workerMachines .Items {
343
+ workerMachineNames [i ] = workerMachine .Name
344
+ }
345
+ if len (workerMachineNames ) > 0 {
346
+ descendants = append (descendants , "Worker machines: " + strings .Join (workerMachineNames , "," ))
347
+ }
348
+ return strings .Join (descendants , ";" )
349
+ }
350
+
317
351
// listDescendants returns a list of all MachineDeployments, MachineSets, and Machines for the cluster.
318
352
func (r * ClusterReconciler ) listDescendants (ctx context.Context , cluster * clusterv1.Cluster ) (clusterDescendants , error ) {
319
353
var descendants clusterDescendants
0 commit comments