Skip to content

Commit

Permalink
Added nodeVolumeDetachTimeout to CP machine
Browse files Browse the repository at this point in the history
Added UT's
  • Loading branch information
snehala27 committed Feb 7, 2023
1 parent c9dec31 commit c8a9a50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 4 additions & 5 deletions controlplane/kubeadm/internal/controllers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,12 @@ func (r *KubeadmControlPlaneReconciler) generateMachine(ctx context.Context, kcp
Bootstrap: clusterv1.Bootstrap{
ConfigRef: bootstrapRef,
},
FailureDomain: failureDomain,
NodeDrainTimeout: kcp.Spec.MachineTemplate.NodeDrainTimeout,
FailureDomain: failureDomain,
NodeDrainTimeout: kcp.Spec.MachineTemplate.NodeDrainTimeout,
NodeDeletionTimeout: kcp.Spec.MachineTemplate.NodeDeletionTimeout,
NodeVolumeDetachTimeout: kcp.Spec.MachineTemplate.NodeVolumeDetachTimeout,
},
}
if kcp.Spec.MachineTemplate.NodeDeletionTimeout != nil {
machine.Spec.NodeDeletionTimeout = kcp.Spec.MachineTemplate.NodeDeletionTimeout
}

// Machine's bootstrap config may be missing ClusterConfiguration if it is not the first machine in the control plane.
// We store ClusterConfiguration as annotation here to detect any changes in KCP ClusterConfiguration and rollout the machine if any.
Expand Down
11 changes: 9 additions & 2 deletions controlplane/kubeadm/internal/controllers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"testing"
"time"

. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -515,7 +516,10 @@ func TestKubeadmControlPlaneReconciler_generateMachine(t *testing.T) {
Spec: controlplanev1.KubeadmControlPlaneSpec{
Version: "v1.16.6",
MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{
ObjectMeta: kcpMachineTemplateObjectMeta,
ObjectMeta: kcpMachineTemplateObjectMeta,
NodeVolumeDetachTimeout: &metav1.Duration{Duration: 10 * time.Second},
NodeDeletionTimeout: &metav1.Duration{Duration: 10 * time.Second},
NodeDrainTimeout: &metav1.Duration{Duration: 10 * time.Second},
},
},
}
Expand All @@ -538,7 +542,10 @@ func TestKubeadmControlPlaneReconciler_generateMachine(t *testing.T) {
Bootstrap: clusterv1.Bootstrap{
ConfigRef: bootstrapRef.DeepCopy(),
},
InfrastructureRef: *infraRef.DeepCopy(),
InfrastructureRef: *infraRef.DeepCopy(),
NodeVolumeDetachTimeout: &metav1.Duration{Duration: 10 * time.Second},
NodeDeletionTimeout: &metav1.Duration{Duration: 10 * time.Second},
NodeDrainTimeout: &metav1.Duration{Duration: 10 * time.Second},
}
r := &KubeadmControlPlaneReconciler{
Client: fakeClient,
Expand Down

0 comments on commit c8a9a50

Please sign in to comment.