Skip to content

Commit

Permalink
Don't consider nodes with exclude-from-external-load-balancer eligibl…
Browse files Browse the repository at this point in the history
…e worker nodes in e2e

The NLB instance target e2e tests in particular considers all nodes eligible targets. This on kOps, which labels control plane nodes with the exclude-from-external-load-balancer label.
  • Loading branch information
Ole Markus With committed May 16, 2021
1 parent 2577491 commit c7dc98b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
12 changes: 9 additions & 3 deletions test/e2e/service/nlb_instance_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ func (s *NLBInstanceTestStack) GetLoadBalancerIngressHostName() string {
}

func (s *NLBInstanceTestStack) GetWorkerNodes(ctx context.Context, f *framework.Framework) ([]corev1.Node, error) {
nodeList := &corev1.NodeList{}
err := f.K8sClient.List(ctx, nodeList)
allNodes := &corev1.NodeList{}
err := f.K8sClient.List(ctx, allNodes)
if err != nil {
return nil, err
}
return nodeList.Items, nil
nodeList := []corev1.Node{}
for _, node := range allNodes.Items {
if _, notarget := node.Labels["node.kubernetes.io/exclude-from-external-load-balancers"]; !notarget {
nodeList = append(nodeList, node)
}
}
return nodeList, nil
}

func (s *NLBInstanceTestStack) ApplyNodeLabels(ctx context.Context, f *framework.Framework, node *corev1.Node, labels map[string]string) error {
Expand Down
15 changes: 6 additions & 9 deletions test/e2e/service/nlb_instance_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ var _ = Describe("test k8s service reconciled by the aws load balancer controlle
})

By("verifying AWS loadbalancer resources", func() {
nodeList := &corev1.NodeList{}
err := tf.K8sClient.List(ctx, nodeList)
nodeList, err := stack.GetWorkerNodes(ctx, tf)
Expect(err).ToNot(HaveOccurred())
err = verifyAWSLoadBalancerResources(ctx, tf, lbARN, LoadBalancerExpectation{
Type: "network",
Scheme: "internet-facing",
TargetType: "instance",
Listeners: stack.resourceStack.getListenersPortMap(),
TargetGroups: stack.resourceStack.getTargetGroupNodePortMap(),
NumTargets: len(nodeList.Items),
NumTargets: len(nodeList),
TargetGroupHC: &TargetGroupHC{
Protocol: "TCP",
Port: "traffic-port",
Expand All @@ -69,10 +68,9 @@ var _ = Describe("test k8s service reconciled by the aws load balancer controlle
Expect(err).NotTo(HaveOccurred())
})
By("waiting for target group targets to be healthy", func() {
nodeList := &corev1.NodeList{}
err := tf.K8sClient.List(ctx, nodeList)
nodeList, err := stack.GetWorkerNodes(ctx, tf)
Expect(err).ToNot(HaveOccurred())
err = waitUntilTargetsAreHealthy(ctx, tf, lbARN, len(nodeList.Items))
err = waitUntilTargetsAreHealthy(ctx, tf, lbARN, len(nodeList))
Expect(err).NotTo(HaveOccurred())
})
By("waiting until DNS name is available", func() {
Expand Down Expand Up @@ -174,16 +172,15 @@ var _ = Describe("test k8s service reconciled by the aws load balancer controlle
Expect(lbARN).ToNot(BeEmpty())
})
By("verifying AWS loadbalancer resources", func() {
nodeList := &corev1.NodeList{}
err := tf.K8sClient.List(ctx, nodeList)
nodeList, err := stack.GetWorkerNodes(ctx, tf)
Expect(err).ToNot(HaveOccurred())
err = verifyAWSLoadBalancerResources(ctx, tf, lbARN, LoadBalancerExpectation{
Type: "network",
Scheme: "internal",
TargetType: "instance",
Listeners: stack.resourceStack.getListenersPortMap(),
TargetGroups: stack.resourceStack.getTargetGroupNodePortMap(),
NumTargets: len(nodeList.Items),
NumTargets: len(nodeList),
TargetGroupHC: &TargetGroupHC{
Protocol: "TCP",
Port: "traffic-port",
Expand Down

0 comments on commit c7dc98b

Please sign in to comment.