Skip to content

Commit 59aa8e4

Browse files
authored
Merge pull request #7727 from fabriziopandini/KCP-should-avoid-early-reconcile-certificates
🌱 KCP should avoid to reconcile certificates too early
2 parents 51b0846 + 9ce7e66 commit 59aa8e4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

controlplane/kubeadm/internal/controllers/controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,11 @@ func (r *KubeadmControlPlaneReconciler) reconcileCertificateExpiries(ctx context
624624
return ctrl.Result{}, nil
625625
}
626626

627+
// Return if KCP is not yet initialized (no API server to contact for checking certificate expiration).
628+
if !controlPlane.KCP.Status.Initialized {
629+
return ctrl.Result{}, nil
630+
}
631+
627632
// Ignore machines which are being deleted.
628633
machines := controlPlane.Machines.Filter(collections.Not(collections.HasDeletionTimestamp))
629634

controlplane/kubeadm/internal/controllers/controller_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,9 @@ func TestReconcileCertificateExpiries(t *testing.T) {
918918
detectedExpiry := time.Now().Add(25 * 24 * time.Hour)
919919

920920
cluster := newCluster(&types.NamespacedName{Name: "foo", Namespace: metav1.NamespaceDefault})
921-
kcp := &controlplanev1.KubeadmControlPlane{}
921+
kcp := &controlplanev1.KubeadmControlPlane{
922+
Status: controlplanev1.KubeadmControlPlaneStatus{Initialized: true},
923+
}
922924
machineWithoutExpiryAnnotation := &clusterv1.Machine{
923925
ObjectMeta: metav1.ObjectMeta{
924926
Name: "machineWithoutExpiryAnnotation",

0 commit comments

Comments
 (0)