Skip to content

Commit

Permalink
Stefan comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Dec 5, 2023
1 parent 9010596 commit a2e25e8
Showing 1 changed file with 1 addition and 53 deletions.
54 changes: 1 addition & 53 deletions controlplane/kubeadm/internal/controllers/remediation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func TestReconcileUnhealthyMachines(t *testing.T) {

g.Expect(env.Cleanup(ctx, m)).To(Succeed())
})
t.Run("Remediation does not happen if there is another machine being deleted (not the one to be remediated", func(t *testing.T) {
t.Run("Remediation does not happen if there is another machine being deleted (not the one to be remediated)", func(t *testing.T) {
g := NewWithT(t)

m1 := createMachine(ctx, g, ns.Name, "m1-unhealthy-", withMachineHealthCheckFailed())
Expand Down Expand Up @@ -910,58 +910,6 @@ func TestReconcileUnhealthyMachines(t *testing.T) {
removeFinalizer(g, m1)
g.Expect(env.Cleanup(ctx, m1, m2, m3)).To(Succeed())
})
t.Run("Remediation deletes unhealthy machine which failed to provision - 3 CP", func(t *testing.T) {
g := NewWithT(t)

m1 := createMachine(ctx, g, ns.Name, "m1-unhealthy-", withMachineHealthCheckFailed(), withWaitBeforeDeleteFinalizer(), withoutNodeRef())
m2 := createMachine(ctx, g, ns.Name, "m2-healthy-", withHealthyEtcdMember())
m3 := createMachine(ctx, g, ns.Name, "m3-healthy-", withHealthyEtcdMember())

controlPlane := &internal.ControlPlane{
KCP: &controlplanev1.KubeadmControlPlane{
Spec: controlplanev1.KubeadmControlPlaneSpec{
Replicas: utilpointer.Int32(3),
Version: "v1.19.1",
},
Status: controlplanev1.KubeadmControlPlaneStatus{
Initialized: true,
},
},
Cluster: &clusterv1.Cluster{},
Machines: collections.FromMachines(m1, m2, m3),
}

r := &KubeadmControlPlaneReconciler{
Client: env.GetClient(),
recorder: record.NewFakeRecorder(32),
managementCluster: &fakeManagementCluster{
Workload: fakeWorkloadCluster{
EtcdMembersResult: nodes(controlPlane.Machines),
},
},
}
controlPlane.InjectTestManagementCluster(r.managementCluster)

ret, err := r.reconcileUnhealthyMachines(ctx, controlPlane)

g.Expect(ret.IsZero()).To(BeFalse()) // Remediation completed, requeue
g.Expect(err).ToNot(HaveOccurred())

g.Expect(controlPlane.KCP.Annotations).To(HaveKey(controlplanev1.RemediationInProgressAnnotation))
remediationData, err := RemediationDataFromAnnotation(controlPlane.KCP.Annotations[controlplanev1.RemediationInProgressAnnotation])
g.Expect(err).ToNot(HaveOccurred())
g.Expect(remediationData.Machine).To(Equal(m1.Name))
g.Expect(remediationData.RetryCount).To(Equal(0))

assertMachineCondition(ctx, g, m1, clusterv1.MachineOwnerRemediatedCondition, corev1.ConditionFalse, clusterv1.RemediationInProgressReason, clusterv1.ConditionSeverityWarning, "")

err = env.Get(ctx, client.ObjectKey{Namespace: m1.Namespace, Name: m1.Name}, m1)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(m1.ObjectMeta.DeletionTimestamp.IsZero()).To(BeFalse())

removeFinalizer(g, m1)
g.Expect(env.Cleanup(ctx, m1, m2, m3)).To(Succeed())
})
t.Run("Remediation deletes unhealthy machine - 4 CP (during 3 CP rolling upgrade)", func(t *testing.T) {
g := NewWithT(t)

Expand Down

0 comments on commit a2e25e8

Please sign in to comment.