Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Sep 10, 2024
1 parent 6c93009 commit ad2be97
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions test/e2e/cluster_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,22 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass with a HA
wlClient := managementClusterProxy.GetWorkloadCluster(ctx, workloadClusterNamespace, workloadClusterName).GetClient()
nodes := corev1.NodeList{}
if err := wlClient.List(ctx, &nodes); err != nil {
return 0, errors.New("failed to list nodes in workload cluster")
return 0, errors.Wrapf(err, "failed to list nodes in workload cluster")
}

kubeProxyPods := corev1.PodList{}
if err := wlClient.List(ctx, &kubeProxyPods, client.InNamespace(metav1.NamespaceSystem), client.MatchingLabels{"k8s-app": "kube-proxy"}); err != nil {
return 0, errors.New("failed to list kube-proxy pods in workload cluster")
return 0, errors.Wrapf(err, "failed to list kube-proxy pods in workload cluster")
}

errList := []error{}

// Check all nodes to be Ready.
for _, node := range nodes.Items {
for _, condition := range node.Status.Conditions {
if condition.Type != corev1.NodeReady || condition.Status == corev1.ConditionTrue {
continue
if condition.Type == corev1.NodeReady && condition.Status != corev1.ConditionTrue {
errList = append(errList, errors.Errorf("Expected the Ready condition for Node %s to be true but got %s instead: %s", node.GetName(), condition.Status, condition.Message))
}
errList = append(errList, errors.Errorf("Node's %s Ready condition is false", node.GetName()))
}
}

Expand All @@ -154,10 +153,9 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass with a HA
}
for _, pod := range kubeProxyPods.Items {
for _, condition := range pod.Status.Conditions {
if condition.Type != corev1.PodReady || condition.Status == corev1.ConditionTrue {
continue
if condition.Type == corev1.PodReady && condition.Status != corev1.ConditionTrue {
errList = append(errList, errors.Errorf("Expected the Ready condition for Pod %s to be true but got %s instead: %s", pod.GetName(), condition.Status, condition.Message))
}
errList = append(errList, errors.Errorf("Pod's %s Ready condition is false", pod.GetName()))
}
}

Expand All @@ -175,12 +173,12 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass with a HA
m := &deletingMachinesWithPreDrainHook[0]
patchHelper, err := patch.NewHelper(m, managementClusterProxy.GetClient())
if err != nil {
return 0, errors.Wrapf(err, "creating patchHelper for Machine %s", klog.KObj(m))
return 0, err
}
delete(m.Annotations, preDrainHook)

if err := patchHelper.Patch(ctx, m); err != nil {
return 0, errors.Wrapf(err, "failed to remove pre-drain annotation from Machine %s", klog.KObj(m))
return 0, err
}

// Return to enter the function again.
Expand Down

0 comments on commit ad2be97

Please sign in to comment.