Skip to content

Commit

Permalink
KCP should avoid to reconcile certificates too early
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini authored and k8s-infra-cherrypick-robot committed Dec 13, 2022
1 parent 3b886d7 commit ba85c18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions controlplane/kubeadm/internal/controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,11 @@ func (r *KubeadmControlPlaneReconciler) reconcileCertificateExpiries(ctx context
return ctrl.Result{}, nil
}

// Return if KCP is not yet initialized (no API server to contact for checking certificate expiration).
if !controlPlane.KCP.Status.Initialized {
return ctrl.Result{}, nil
}

// Ignore machines which are being deleted.
machines := controlPlane.Machines.Filter(collections.Not(collections.HasDeletionTimestamp))

Expand Down
4 changes: 3 additions & 1 deletion controlplane/kubeadm/internal/controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,9 @@ func TestReconcileCertificateExpiries(t *testing.T) {
detectedExpiry := time.Now().Add(25 * 24 * time.Hour)

cluster := newCluster(&types.NamespacedName{Name: "foo", Namespace: metav1.NamespaceDefault})
kcp := &controlplanev1.KubeadmControlPlane{}
kcp := &controlplanev1.KubeadmControlPlane{
Status: controlplanev1.KubeadmControlPlaneStatus{Initialized: true},
}
machineWithoutExpiryAnnotation := &clusterv1.Machine{
ObjectMeta: metav1.ObjectMeta{
Name: "machineWithoutExpiryAnnotation",
Expand Down

0 comments on commit ba85c18

Please sign in to comment.