@@ -210,8 +210,6 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
210
210
return ctrl.Result {}, nil
211
211
}
212
212
213
- s := & scope {}
214
-
215
213
defer func () {
216
214
// Always attempt to update status.
217
215
if err := r .updateStatus (ctx , controlPlane ); err != nil {
@@ -224,7 +222,7 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
224
222
}
225
223
}
226
224
227
- r .updateV1Beta2Status (ctx , controlPlane , s )
225
+ r .updateV1Beta2Status (ctx , controlPlane )
228
226
229
227
// Always attempt to Patch the KubeadmControlPlane object and status after each reconciliation.
230
228
patchOpts := []patch.Option {}
@@ -258,7 +256,7 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
258
256
259
257
if ! kcp .ObjectMeta .DeletionTimestamp .IsZero () {
260
258
// Handle deletion reconciliation loop.
261
- res , err = r .reconcileDelete (ctx , controlPlane , s )
259
+ res , err = r .reconcileDelete (ctx , controlPlane )
262
260
if errors .Is (err , clustercache .ErrClusterNotConnected ) {
263
261
log .V (5 ).Info ("Requeuing because connection to the workload cluster is down" )
264
262
return ctrl.Result {RequeueAfter : time .Minute }, nil
@@ -591,26 +589,17 @@ func (r *KubeadmControlPlaneReconciler) reconcileClusterCertificates(ctx context
591
589
return nil
592
590
}
593
591
594
- // scope holds the different objects that are read and used during the reconcile.
595
- type scope struct {
596
- // deletingReason is the reason that should be used when setting the Deleting condition.
597
- deletingReason string
598
-
599
- // deletingMessage is the message that should be used when setting the Deleting condition.
600
- deletingMessage string
601
- }
602
-
603
592
// reconcileDelete handles KubeadmControlPlane deletion.
604
593
// The implementation does not take non-control plane workloads into consideration. This may or may not change in the future.
605
594
// Please see https://github.com/kubernetes-sigs/cluster-api/issues/2064.
606
- func (r * KubeadmControlPlaneReconciler ) reconcileDelete (ctx context.Context , controlPlane * internal.ControlPlane , s * scope ) (ctrl.Result , error ) {
595
+ func (r * KubeadmControlPlaneReconciler ) reconcileDelete (ctx context.Context , controlPlane * internal.ControlPlane ) (ctrl.Result , error ) {
607
596
log := ctrl .LoggerFrom (ctx )
608
597
log .Info ("Reconcile KubeadmControlPlane deletion" )
609
598
610
599
// If no control plane machines remain, remove the finalizer
611
600
if len (controlPlane .Machines ) == 0 {
612
- s . deletingReason = controlplanev1 .KubeadmControlPlaneDeletingDeletionCompletedV1Beta2Reason
613
- s . deletingMessage = ""
601
+ controlPlane . DeletingReason = controlplanev1 .KubeadmControlPlaneDeletingDeletionCompletedV1Beta2Reason
602
+ controlPlane . DeletingMessage = ""
614
603
615
604
controllerutil .RemoveFinalizer (controlPlane .KCP , controlplanev1 .KubeadmControlPlaneFinalizer )
616
605
return ctrl.Result {}, nil
@@ -631,8 +620,8 @@ func (r *KubeadmControlPlaneReconciler) reconcileDelete(ctx context.Context, con
631
620
// Gets all machines, not just control plane machines.
632
621
allMachines , err := r .managementCluster .GetMachinesForCluster (ctx , controlPlane .Cluster )
633
622
if err != nil {
634
- s . deletingReason = controlplanev1 .KubeadmControlPlaneDeletingInternalErrorV1Beta2Reason
635
- s . deletingMessage = "Please check controller logs for errors" //nolint:goconst // Not making this a constant for now
623
+ controlPlane . DeletingReason = controlplanev1 .KubeadmControlPlaneDeletingInternalErrorV1Beta2Reason
624
+ controlPlane . DeletingMessage = "Please check controller logs for errors" //nolint:goconst // Not making this a constant for now
636
625
return ctrl.Result {}, err
637
626
}
638
627
@@ -641,8 +630,8 @@ func (r *KubeadmControlPlaneReconciler) reconcileDelete(ctx context.Context, con
641
630
if feature .Gates .Enabled (feature .MachinePool ) {
642
631
allMachinePools , err = r .managementCluster .GetMachinePoolsForCluster (ctx , controlPlane .Cluster )
643
632
if err != nil {
644
- s . deletingReason = controlplanev1 .KubeadmControlPlaneDeletingInternalErrorV1Beta2Reason
645
- s . deletingMessage = "Please check controller logs for errors"
633
+ controlPlane . DeletingReason = controlplanev1 .KubeadmControlPlaneDeletingInternalErrorV1Beta2Reason
634
+ controlPlane . DeletingMessage = "Please check controller logs for errors"
646
635
return ctrl.Result {}, err
647
636
}
648
637
}
@@ -651,8 +640,8 @@ func (r *KubeadmControlPlaneReconciler) reconcileDelete(ctx context.Context, con
651
640
log .Info ("Waiting for worker nodes to be deleted first" )
652
641
conditions .MarkFalse (controlPlane .KCP , controlplanev1 .ResizedCondition , clusterv1 .DeletingReason , clusterv1 .ConditionSeverityInfo , "Waiting for worker nodes to be deleted first" )
653
642
654
- s . deletingReason = controlplanev1 .KubeadmControlPlaneDeletingWaitingForWorkersDeletionV1Beta2Reason
655
- s . deletingMessage = objectsPendingDeleteNames (allMachines , allMachinePools , controlPlane .Cluster )
643
+ controlPlane . DeletingReason = controlplanev1 .KubeadmControlPlaneDeletingWaitingForWorkersDeletionV1Beta2Reason
644
+ controlPlane . DeletingMessage = objectsPendingDeleteNames (allMachines , allMachinePools , controlPlane .Cluster )
656
645
return ctrl.Result {RequeueAfter : deleteRequeueAfter }, nil
657
646
}
658
647
@@ -689,8 +678,8 @@ func (r *KubeadmControlPlaneReconciler) reconcileDelete(ctx context.Context, con
689
678
r .recorder .Eventf (controlPlane .KCP , corev1 .EventTypeWarning , "FailedDelete" ,
690
679
"Failed to delete control plane Machines for cluster %s control plane: %v" , klog .KObj (controlPlane .Cluster ), err )
691
680
692
- s . deletingReason = controlplanev1 .KubeadmControlPlaneDeletingInternalErrorV1Beta2Reason
693
- s . deletingMessage = "Please check controller logs for errors"
681
+ controlPlane . DeletingReason = controlplanev1 .KubeadmControlPlaneDeletingInternalErrorV1Beta2Reason
682
+ controlPlane . DeletingMessage = "Please check controller logs for errors"
694
683
return ctrl.Result {}, err
695
684
}
696
685
@@ -710,8 +699,8 @@ func (r *KubeadmControlPlaneReconciler) reconcileDelete(ctx context.Context, con
710
699
message += fmt .Sprintf (" and %s" , staleMessage )
711
700
}
712
701
}
713
- s . deletingReason = controlplanev1 .KubeadmControlPlaneDeletingWaitingForMachineDeletionV1Beta2Reason
714
- s . deletingMessage = message
702
+ controlPlane . DeletingReason = controlplanev1 .KubeadmControlPlaneDeletingWaitingForMachineDeletionV1Beta2Reason
703
+ controlPlane . DeletingMessage = message
715
704
return ctrl.Result {RequeueAfter : deleteRequeueAfter }, nil
716
705
}
717
706
0 commit comments