Skip to content

Commit ab008a5

Browse files
Merge pull request #30954 from tthvo/test/ccm-sdkv2
OCPBUGS-81640: test/ccm: upgrade ccm healthz test to use aws sdk v2
2 parents f6d810f + 02d9814 commit ab008a5

File tree

498 files changed

+138002
-22025
lines changed

Some content is hidden

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

498 files changed

+138002
-22025
lines changed

go.mod

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ require (
2828
github.com/RangelReale/osincli v0.0.0-20160924135400-fababb0555f2
2929
github.com/apparentlymart/go-cidr v1.1.0
3030
github.com/aws/aws-sdk-go v1.55.8
31+
github.com/aws/aws-sdk-go-v2 v1.41.5
32+
github.com/aws/aws-sdk-go-v2/config v1.29.14
33+
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.33.23
34+
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.54.10
3135
github.com/blang/semver/v4 v4.0.0
3236
github.com/coreos/stream-metadata-go v0.4.9
3337
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
@@ -170,6 +174,17 @@ require (
170174
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
171175
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2 // indirect
172176
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
177+
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 // indirect
178+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
179+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 // indirect
180+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 // indirect
181+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
182+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
183+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
184+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
185+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
186+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
187+
github.com/aws/smithy-go v1.24.2 // indirect
173188
github.com/beorn7/perks v1.0.1 // indirect
174189
github.com/campoy/embedmd v1.0.0 // indirect
175190
github.com/cenkalti/backoff/v4 v4.3.0 // indirect

go.sum

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,36 @@ github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3d
222222
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
223223
github.com/aws/aws-sdk-go v1.55.8 h1:JRmEUbU52aJQZ2AjX4q4Wu7t4uZjOu71uyNmaWlUkJQ=
224224
github.com/aws/aws-sdk-go v1.55.8/go.mod h1:ZkViS9AqA6otK+JBBNH2++sx1sgxrPKcSzPPvQkUtXk=
225+
github.com/aws/aws-sdk-go-v2 v1.41.5 h1:dj5kopbwUsVUVFgO4Fi5BIT3t4WyqIDjGKCangnV/yY=
226+
github.com/aws/aws-sdk-go-v2 v1.41.5/go.mod h1:mwsPRE8ceUUpiTgF7QmQIJ7lgsKUPQOUl3o72QBrE1o=
227+
github.com/aws/aws-sdk-go-v2/config v1.29.14 h1:f+eEi/2cKCg9pqKBoAIwRGzVb70MRKqWX4dg1BDcSJM=
228+
github.com/aws/aws-sdk-go-v2/config v1.29.14/go.mod h1:wVPHWcIFv3WO89w0rE10gzf17ZYy+UVS1Geq8Iei34g=
229+
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 h1:9KxtdcIA/5xPNQyZRgUSpYOE6j9Bc4+D7nZua0KGYOM=
230+
github.com/aws/aws-sdk-go-v2/credentials v1.17.67/go.mod h1:p3C44m+cfnbv763s52gCqrjaqyPikj9Sg47kUVaNZQQ=
231+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 h1:x793wxmUWVDhshP8WW2mlnXuFrO4cOd3HLBroh1paFw=
232+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30/go.mod h1:Jpne2tDnYiFascUEs2AWHJL9Yp7A5ZVy3TNyxaAjD6M=
233+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 h1:Rgg6wvjjtX8bNHcvi9OnXWwcE0a2vGpbwmtICOsvcf4=
234+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21/go.mod h1:A/kJFst/nm//cyqonihbdpQZwiUhhzpqTsdbhDdRF9c=
235+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 h1:PEgGVtPoB6NTpPrBgqSE5hE/o47Ij9qk/SEZFbUOe9A=
236+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21/go.mod h1:p+hz+PRAYlY3zcpJhPwXlLC4C+kqn70WIHwnzAfs6ps=
237+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d2KyU5X/BZxjOkRo=
238+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo=
239+
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.33.23 h1:sLj6B5YHp6RqyAf5lF5BxzyGxZIxXG1NW3mo0jtpDqo=
240+
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.33.23/go.mod h1:64UwjvWmvtc6HN/hbnZmLQbh+sFsqRUo8693mOu9LB4=
241+
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.54.10 h1:RRItb+JMcIGZSiNKLViw9fCYxQaahR+BaswSF3LkHEk=
242+
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.54.10/go.mod h1:qogon7Vx0cwiCEkU3x9/42gzUZbHoAr+ADGdLVHRVks=
243+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b5IzM/lum78bZ590jy36+d/aFLgKF/4Vd1xPE=
244+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA=
245+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2F1JbDaGooxTq18wmmFzbJRfXfVfy96/1CXM=
246+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY=
247+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 h1:1Gw+9ajCV1jogloEv1RRnvfRFia2cL6c9cuKV2Ps+G8=
248+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI=
249+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 h1:hXmVKytPfTy5axZ+fYbR5d0cFmC3JvwLm5kM83luako=
250+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs=
251+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 h1:1XuUZ8mYJw9B6lzAkXhqHlJd/XvaX32evhproijJEZY=
252+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4=
253+
github.com/aws/smithy-go v1.24.2 h1:FzA3bu/nt/vDvmnkg+R8Xl46gmzEDam6mZ1hzmwXFng=
254+
github.com/aws/smithy-go v1.24.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
225255
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
226256
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
227257
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=

test/extended/cloud_controller_manager/ccm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ spec:
150150
healthCheckPath := "/healthz"
151151
exutil.GetAwsCredentialFromCluster(oc)
152152
region := exutil.GetClusterRegion(oc)
153-
sess := exutil.InitAwsSession(region)
154-
elbClient := exutil.NewELBClient(sess)
153+
config := exutil.InitAwsConfig(region)
154+
elbClient := exutil.NewELBClient(config)
155155

156156
expectedHealthCheck := fmt.Sprintf("HTTP:%s%s", healthCheckPort, healthCheckPath)
157157
var healthCheck string

test/extended/util/aws_client.go

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package util
22

33
import (
4+
"context"
45
"encoding/base64"
56
"fmt"
67
"os"
78

8-
"github.com/aws/aws-sdk-go/aws"
9+
"github.com/aws/aws-sdk-go-v2/aws"
10+
"github.com/aws/aws-sdk-go-v2/config"
11+
elb "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing"
12+
elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
13+
awsv1 "github.com/aws/aws-sdk-go/aws"
914
"github.com/aws/aws-sdk-go/aws/session"
10-
"github.com/aws/aws-sdk-go/service/elb"
11-
"github.com/aws/aws-sdk-go/service/elbv2"
1215
g "github.com/onsi/ginkgo/v2"
1316
o "github.com/onsi/gomega"
1417
"github.com/tidwall/gjson"
@@ -39,36 +42,44 @@ func GetAwsCredentialFromCluster(oc *CLI) {
3942
// InitAwsSession init session
4043
func InitAwsSession(region string) *session.Session {
4144
sess := session.Must(session.NewSessionWithOptions(session.Options{
42-
Config: aws.Config{
43-
Region: aws.String(region),
45+
Config: awsv1.Config{
46+
Region: awsv1.String(region),
4447
},
4548
}))
4649

4750
return sess
4851
}
4952

5053
type ELBClient struct {
51-
svc *elb.ELB
52-
svcV2 *elbv2.ELBV2
54+
svc *elb.Client
55+
svcV2 *elbv2.Client
5356
}
5457

55-
// NewELBClient creates an ECRClient
56-
func NewELBClient(sess *session.Session) *ELBClient {
58+
// InitAwsConfig init AWS config (AWS SDK v2)
59+
func InitAwsConfig(region string) aws.Config {
60+
cfg, err := config.LoadDefaultConfig(context.TODO(),
61+
config.WithRegion(region),
62+
)
63+
o.Expect(err).NotTo(o.HaveOccurred())
64+
65+
return cfg
66+
}
67+
68+
// NewELBClient creates an ELBClient
69+
func NewELBClient(cfg aws.Config) *ELBClient {
5770
return &ELBClient{
58-
svc: elb.New(sess),
59-
svcV2: elbv2.New(sess),
71+
svc: elb.NewFromConfig(cfg),
72+
svcV2: elbv2.NewFromConfig(cfg),
6073
}
6174
}
6275

6376
// GetLBHealthCheckPortPath get load balance health check port and path for Classic Load Balancer
6477
func (elbClient *ELBClient) GetCLBHealthCheckPortPath(lbName string) (string, error) {
6578
input := &elb.DescribeLoadBalancersInput{
66-
LoadBalancerNames: []*string{
67-
aws.String(lbName),
68-
},
79+
LoadBalancerNames: []string{lbName},
6980
}
7081

71-
result, err := elbClient.svc.DescribeLoadBalancers(input)
82+
result, err := elbClient.svc.DescribeLoadBalancers(context.TODO(), input)
7283
if err != nil {
7384
e2e.Logf("Failed to describe classic load balancer: %v", err)
7485
return "", err
@@ -89,9 +100,9 @@ func (elbClient *ELBClient) GetCLBHealthCheckPortPath(lbName string) (string, er
89100
func (elbClient *ELBClient) GetNLBHealthCheckPortPath(lbName string) (string, error) {
90101
// Describe the load balancer
91102
input := &elbv2.DescribeLoadBalancersInput{
92-
Names: []*string{aws.String(lbName)},
103+
Names: []string{lbName},
93104
}
94-
result, err := elbClient.svcV2.DescribeLoadBalancers(input)
105+
result, err := elbClient.svcV2.DescribeLoadBalancers(context.TODO(), input)
95106
if err != nil {
96107
e2e.Logf("Failed to describe NLB: %v", err)
97108
return "", err
@@ -106,7 +117,7 @@ func (elbClient *ELBClient) GetNLBHealthCheckPortPath(lbName string) (string, er
106117
tgInput := &elbv2.DescribeTargetGroupsInput{
107118
LoadBalancerArn: result.LoadBalancers[0].LoadBalancerArn,
108119
}
109-
tgResult, err := elbClient.svcV2.DescribeTargetGroups(tgInput)
120+
tgResult, err := elbClient.svcV2.DescribeTargetGroups(context.TODO(), tgInput)
110121
if err != nil {
111122
e2e.Logf("Failed to describe target groups: %v", err)
112123
return "", err
@@ -119,9 +130,9 @@ func (elbClient *ELBClient) GetNLBHealthCheckPortPath(lbName string) (string, er
119130

120131
// Get health check configuration from the first target group
121132
tg := tgResult.TargetGroups[0]
122-
protocol := aws.StringValue(tg.HealthCheckProtocol)
123-
path := aws.StringValue(tg.HealthCheckPath)
124-
port := aws.StringValue(tg.HealthCheckPort)
133+
protocol := string(tg.HealthCheckProtocol)
134+
path := aws.ToString(tg.HealthCheckPath)
135+
port := aws.ToString(tg.HealthCheckPort)
125136

126137
// Format: "HTTP:10256/healthz"
127138
return fmt.Sprintf("%s:%s%s", protocol, port, path), nil

0 commit comments

Comments
 (0)