Skip to content

Commit 522e627

Browse files
committed
handle minReadySeconds and improve coverage
Signed-off-by: sivchari <[email protected]>
1 parent 83456b0 commit 522e627

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

controlplane/kubeadm/internal/controllers/controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ func (r *KubeadmControlPlaneReconciler) ClusterToKubeadmControlPlane(_ context.C
775775
// "metadata.annotations" from "manager" so that "capi-kubeadmcontrolplane" can own these fields and can work with SSA.
776776
// Otherwise, fields would be co-owned by our "old" "manager" and "capi-kubeadmcontrolplane" and then we would not be
777777
// able to e.g. drop labels and annotations.
778+
// Note: We intentionally don't set "minReadySeconds" on Machines because we consider enough to have machine availability.
778779
func (r *KubeadmControlPlaneReconciler) syncMachines(ctx context.Context, controlPlane *internal.ControlPlane) error {
779780
patchHelpers := map[string]*patch.Helper{}
780781
for machineName := range controlPlane.Machines {

controlplane/kubeadm/internal/controllers/helpers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ func (r *KubeadmControlPlaneReconciler) updateMachine(ctx context.Context, machi
361361
// There are small differences in how we calculate the Machine depending on if it
362362
// is a create or update. Example: for a new Machine we have to calculate a new name,
363363
// while for an existing Machine we have to use the name of the existing Machine.
364+
// Note: We intentionally don't set "minReadySeconds" on Machines because we consider enough to have machine availability.
364365
func (r *KubeadmControlPlaneReconciler) computeDesiredMachine(kcp *controlplanev1.KubeadmControlPlane, cluster *clusterv1.Cluster, failureDomain *string, existingMachine *clusterv1.Machine) (*clusterv1.Machine, error) {
365366
var machineName string
366367
var machineUID types.UID

internal/controllers/machinedeployment/machinedeployment_sync_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ func TestComputeDesiredMachineSet(t *testing.T) {
566566
Bootstrap: clusterv1.Bootstrap{
567567
ConfigRef: &bootstrapRef,
568568
},
569+
MinReadySeconds: ptr.To[int32](3),
569570
ReadinessGates: []clusterv1.MachineReadinessGate{{ConditionType: "foo"}},
570571
NodeDrainTimeout: duration10s,
571572
NodeVolumeDetachTimeout: duration10s,
@@ -791,6 +792,9 @@ func assertMachineSet(g *WithT, actualMS *clusterv1.MachineSet, expectedMS *clus
791792
g.Expect(actualMS.Spec.Template.Annotations).Should(HaveKeyWithValue(k, v))
792793
}
793794

795+
// Check MinReadySeconds
796+
g.Expect(actualMS.Spec.Template.Spec.MinReadySeconds).Should(Equal(expectedMS.Spec.Template.Spec.MinReadySeconds))
797+
794798
// Check DeletePolicy
795799
g.Expect(actualMS.Spec.DeletePolicy).Should(Equal(expectedMS.Spec.DeletePolicy))
796800

internal/controllers/machinedeployment/mdutil/util_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ func TestMachineTemplateUpToDate(t *testing.T) {
184184
ClusterName: "cluster1",
185185
Version: ptr.To("v1.25.0"),
186186
FailureDomain: ptr.To("failure-domain1"),
187+
MinReadySeconds: ptr.To[int32](10),
187188
InfrastructureRef: corev1.ObjectReference{
188189
Name: "infra1",
189190
Namespace: "default",

internal/controllers/machineset/machineset_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ func (r *Reconciler) syncMachines(ctx context.Context, s *scope) (ctrl.Result, e
517517
m.Spec.NodeDrainTimeout = machineSet.Spec.Template.Spec.NodeDrainTimeout
518518
m.Spec.NodeDeletionTimeout = machineSet.Spec.Template.Spec.NodeDeletionTimeout
519519
m.Spec.NodeVolumeDetachTimeout = machineSet.Spec.Template.Spec.NodeVolumeDetachTimeout
520+
m.Spec.MinReadySeconds = machineSet.Spec.Template.Spec.MinReadySeconds
520521

521522
// Set machine's up to date condition
522523
if upToDateCondition != nil {
@@ -1200,7 +1201,7 @@ func (r *Reconciler) reconcileV1Beta1Status(ctx context.Context, s *scope) error
12001201

12011202
if noderefutil.IsNodeReady(node) {
12021203
readyReplicasCount++
1203-
if noderefutil.IsNodeAvailable(node, ptr.Deref(machine.Spec.MinReadySeconds, 0), metav1.Now()) {
1204+
if noderefutil.IsNodeAvailable(node, ptr.Deref(ms.Spec.Template.Spec.MinReadySeconds, 0), metav1.Now()) {
12041205
availableReplicasCount++
12051206
}
12061207
} else if machine.GetDeletionTimestamp().IsZero() {

0 commit comments

Comments
 (0)