Skip to content

Commit c10db65

Browse files
Merge pull request #30952 from tthvo/ccm-nlb
OCPCLOUD-3215: test/ccm: add support for verifying NLB health check configuration
2 parents e0e704f + a1131f5 commit c10db65

File tree

54 files changed

+27047
-3022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+27047
-3022
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/Masterminds/semver v1.5.0
2828
github.com/RangelReale/osincli v0.0.0-20160924135400-fababb0555f2
2929
github.com/apparentlymart/go-cidr v1.1.0
30-
github.com/aws/aws-sdk-go v1.50.25
30+
github.com/aws/aws-sdk-go v1.55.8
3131
github.com/blang/semver/v4 v4.0.0
3232
github.com/coreos/stream-metadata-go v0.4.9
3333
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
220220
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
221221
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
222222
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
223-
github.com/aws/aws-sdk-go v1.50.25 h1:vhiHtLYybv1Nhx3Kv18BBC6L0aPJHaG9aeEsr92W99c=
224-
github.com/aws/aws-sdk-go v1.50.25/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
223+
github.com/aws/aws-sdk-go v1.55.8 h1:JRmEUbU52aJQZ2AjX4q4Wu7t4uZjOu71uyNmaWlUkJQ=
224+
github.com/aws/aws-sdk-go v1.55.8/go.mod h1:ZkViS9AqA6otK+JBBNH2++sx1sgxrPKcSzPPvQkUtXk=
225225
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
226226
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
227227
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
@@ -854,8 +854,6 @@ github.com/openshift/apiserver-library-go v0.0.0-20260303173613-cd3676268d31 h1:
854854
github.com/openshift/apiserver-library-go v0.0.0-20260303173613-cd3676268d31/go.mod h1:mnTsMMTtXSPBQzqBp5HXBjLvliveKenRADFQy9m5jc0=
855855
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee h1:+Sp5GGnjHDhT/a/nQ1xdp43UscBMr7G5wxsYotyhzJ4=
856856
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE=
857-
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20260303184444-1cc650aa0565 h1:3/q8qM4HbFa+Een8wgzpwO8W6mO7Po+MwY6uxiXi/ac=
858-
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20260303184444-1cc650aa0565/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
859857
github.com/openshift/client-go v0.0.0-20260302182750-20813ce71ca6 h1:wJv4Ia+R4OxoaJcTUyvMtBc5rWFvfTiEA8d5f1MBPqI=
860858
github.com/openshift/client-go v0.0.0-20260302182750-20813ce71ca6/go.mod h1:3lkVff575BlbDUUhMsrD1IyvfkZ+oKUB7iZuVy1m0W0=
861859
github.com/openshift/kubernetes v0.0.0-20260305123649-d18f3f005eaa h1:4TK07egSJrny442x0Kl0HgzXgt2lnCKTKHF3sbL2U3E=
@@ -916,6 +914,8 @@ github.com/openshift/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20260
916914
github.com/openshift/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20260305123649-d18f3f005eaa/go.mod h1:CnFDBq5NGnfOSMeOP8l4SNYJrxK6Z1kUaKdu3Qq9Uik=
917915
github.com/openshift/library-go v0.0.0-20260303171201-5d9eb6295ff6 h1:xjqy0OolrFdJ+ofI/aD0+2k9+MSk5anP5dXifFt539Q=
918916
github.com/openshift/library-go v0.0.0-20260303171201-5d9eb6295ff6/go.mod h1:D797O/ssKTNglbrGchjIguFq+DbyRYdeds5w4/VTrKM=
917+
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20260303184444-1cc650aa0565 h1:3/q8qM4HbFa+Een8wgzpwO8W6mO7Po+MwY6uxiXi/ac=
918+
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20260303184444-1cc650aa0565/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
919919
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
920920
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
921921
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=

test/extended/cloud_controller_manager/ccm.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,18 @@ spec:
152152
region := exutil.GetClusterRegion(oc)
153153
sess := exutil.InitAwsSession(region)
154154
elbClient := exutil.NewELBClient(sess)
155-
healthCheck, err := elbClient.GetLBHealthCheckPortPath(lbName)
156-
o.Expect(err).NotTo(o.HaveOccurred(), "unable to get health check port and path")
155+
156+
expectedHealthCheck := fmt.Sprintf("HTTP:%s%s", healthCheckPort, healthCheckPath)
157+
var healthCheck string
158+
if isIPv6Primary {
159+
healthCheck, err = elbClient.GetNLBHealthCheckPortPath(lbName)
160+
o.Expect(err).NotTo(o.HaveOccurred(), "unable to get NLB health check port and path")
161+
} else {
162+
healthCheck, err = elbClient.GetCLBHealthCheckPortPath(lbName)
163+
o.Expect(err).NotTo(o.HaveOccurred(), "unable to get CLB health check port and path")
164+
}
157165
e2e.Logf("Health check port and path: %v", healthCheck)
158-
o.Expect(healthCheck).To(o.Equal(fmt.Sprintf("HTTP:%s%s", healthCheckPort, healthCheckPath)))
166+
o.Expect(healthCheck).To(o.Equal(expectedHealthCheck))
159167
})
160168
})
161169

test/extended/util/aws_client.go

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package util
22

33
import (
44
"encoding/base64"
5+
"fmt"
56
"os"
67

78
"github.com/aws/aws-sdk-go/aws"
89
"github.com/aws/aws-sdk-go/aws/session"
910
"github.com/aws/aws-sdk-go/service/elb"
11+
"github.com/aws/aws-sdk-go/service/elbv2"
1012
g "github.com/onsi/ginkgo/v2"
1113
o "github.com/onsi/gomega"
1214
"github.com/tidwall/gjson"
@@ -46,18 +48,20 @@ func InitAwsSession(region string) *session.Session {
4648
}
4749

4850
type ELBClient struct {
49-
svc *elb.ELB
51+
svc *elb.ELB
52+
svcV2 *elbv2.ELBV2
5053
}
5154

5255
// NewELBClient creates an ECRClient
5356
func NewELBClient(sess *session.Session) *ELBClient {
5457
return &ELBClient{
55-
svc: elb.New(sess),
58+
svc: elb.New(sess),
59+
svcV2: elbv2.New(sess),
5660
}
5761
}
5862

59-
// GetLBHealthCheckPortPath get load balance health check port and path
60-
func (elbClient *ELBClient) GetLBHealthCheckPortPath(lbName string) (string, error) {
63+
// GetLBHealthCheckPortPath get load balance health check port and path for Classic Load Balancer
64+
func (elbClient *ELBClient) GetCLBHealthCheckPortPath(lbName string) (string, error) {
6165
input := &elb.DescribeLoadBalancersInput{
6266
LoadBalancerNames: []*string{
6367
aws.String(lbName),
@@ -66,12 +70,12 @@ func (elbClient *ELBClient) GetLBHealthCheckPortPath(lbName string) (string, err
6670

6771
result, err := elbClient.svc.DescribeLoadBalancers(input)
6872
if err != nil {
69-
e2e.Logf("Failed to describe load balancer: %v", err)
73+
e2e.Logf("Failed to describe classic load balancer: %v", err)
7074
return "", err
7175
}
7276

7377
if len(result.LoadBalancerDescriptions) == 0 {
74-
e2e.Logf("Failed to get load balancers: %v", err)
78+
e2e.Logf("Failed to get classic load balancers: %v", err)
7579
}
7680

7781
healthCheck := result.LoadBalancerDescriptions[0].HealthCheck
@@ -80,3 +84,45 @@ func (elbClient *ELBClient) GetLBHealthCheckPortPath(lbName string) (string, err
8084
}
8185
return *healthCheck.Target, nil
8286
}
87+
88+
// GetNLBHealthCheckPortPath get load balance health check port and path for Network/Application Load Balancer
89+
func (elbClient *ELBClient) GetNLBHealthCheckPortPath(lbName string) (string, error) {
90+
// Describe the load balancer
91+
input := &elbv2.DescribeLoadBalancersInput{
92+
Names: []*string{aws.String(lbName)},
93+
}
94+
result, err := elbClient.svcV2.DescribeLoadBalancers(input)
95+
if err != nil {
96+
e2e.Logf("Failed to describe NLB: %v", err)
97+
return "", err
98+
}
99+
100+
if len(result.LoadBalancers) == 0 {
101+
e2e.Logf("No NLB found with name: %s", lbName)
102+
return "", nil
103+
}
104+
105+
// Get target groups for this load balancer
106+
tgInput := &elbv2.DescribeTargetGroupsInput{
107+
LoadBalancerArn: result.LoadBalancers[0].LoadBalancerArn,
108+
}
109+
tgResult, err := elbClient.svcV2.DescribeTargetGroups(tgInput)
110+
if err != nil {
111+
e2e.Logf("Failed to describe target groups: %v", err)
112+
return "", err
113+
}
114+
115+
if len(tgResult.TargetGroups) == 0 {
116+
e2e.Logf("No target groups found for NLB: %s", lbName)
117+
return "", nil
118+
}
119+
120+
// Get health check configuration from the first target group
121+
tg := tgResult.TargetGroups[0]
122+
protocol := aws.StringValue(tg.HealthCheckProtocol)
123+
path := aws.StringValue(tg.HealthCheckPath)
124+
port := aws.StringValue(tg.HealthCheckPort)
125+
126+
// Format: "HTTP:10256/healthz"
127+
return fmt.Sprintf("%s:%s%s", protocol, port, path), nil
128+
}

vendor/github.com/aws/aws-sdk-go/aws/arn/arn.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/aws/aws-sdk-go/aws/auth/bearer/token.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/aws/aws-sdk-go/aws/awserr/error.go

Lines changed: 42 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/aws/aws-sdk-go/aws/awsutil/doc.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/aws/aws-sdk-go/aws/client/client.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)