Skip to content

Commit 9ce7e66

Browse files
KCP should avoid to reconcile certificates too early
1 parent ebd4d3d commit 9ce7e66

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
@@ -621,6 +621,11 @@ func (r *KubeadmControlPlaneReconciler) reconcileCertificateExpiries(ctx context
621621
return ctrl.Result{}, nil
622622
}
623623

624+
// Return if KCP is not yet initialized (no API server to contact for checking certificate expiration).
625+
if !controlPlane.KCP.Status.Initialized {
626+
return ctrl.Result{}, nil
627+
}
628+
624629
// Ignore machines which are being deleted.
625630
machines := controlPlane.Machines.Filter(collections.Not(collections.HasDeletionTimestamp))
626631

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)