Skip to content

Commit d7cab9e

Browse files
Merge pull request #9976 from tthvo/CORS-4078-logs
CORS-4078: allow toggling AWS client logging
2 parents 90dc719 + fd9c351 commit d7cab9e

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

pkg/asset/installconfig/aws/endpoints.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ type ServiceEndpointResolver struct {
6868
// indexed by service ID.
6969
endpoints map[string]typesaws.ServiceEndpoint
7070
endpointOptions EndpointOptions
71-
72-
logger logrus.FieldLogger
7371
}
7472

7573
// NewServiceEndpointResolver returns a new ServiceEndpointResolver.
@@ -81,7 +79,6 @@ func NewServiceEndpointResolver(opts EndpointOptions) *ServiceEndpointResolver {
8179
return &ServiceEndpointResolver{
8280
endpoints: endpointMap,
8381
endpointOptions: opts,
84-
logger: logrus.StandardLogger(),
8582
}
8683
}
8784

@@ -98,11 +95,9 @@ func (s *EC2EndpointResolver) ResolveEndpoint(ctx context.Context, params ec2.En
9895
// If custom endpoint not found, return default endpoint for the service.
9996
endpoint, ok := s.endpoints[ec2.ServiceID]
10097
if !ok {
101-
s.logger.Debug("Custom EC2 endpoint not found, using default endpoint")
10298
return ec2.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)
10399
}
104100

105-
s.logger.Debugf("Custom EC2 endpoint found, using custom endpoint: %s", endpoint.URL)
106101
params.Endpoint = aws.String(endpoint.URL)
107102
params.Region = aws.String(s.endpointOptions.Region)
108103
return ec2.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)
@@ -121,11 +116,9 @@ func (s *IAMEndpointResolver) ResolveEndpoint(ctx context.Context, params iam.En
121116
// If custom endpoint not found, return default endpoint for the service.
122117
endpoint, ok := s.endpoints[iam.ServiceID]
123118
if !ok {
124-
s.logger.Debug("Custom IAM endpoint not found, using default endpoint")
125119
return iam.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)
126120
}
127121

128-
s.logger.Debugf("Custom IAM endpoint found, using custom endpoint: %s", endpoint.URL)
129122
params.Endpoint = aws.String(endpoint.URL)
130123
params.Region = aws.String(s.endpointOptions.Region)
131124
return iam.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)
@@ -144,11 +137,9 @@ func (s *STSEndpointResolver) ResolveEndpoint(ctx context.Context, params sts.En
144137
// If custom endpoint not found, return default endpoint for the service
145138
endpoint, ok := s.endpoints[sts.ServiceID]
146139
if !ok {
147-
s.logger.Debug("Custom STS endpoint not found, using default endpoint")
148140
return sts.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)
149141
}
150142

151-
s.logger.Debugf("Custom STS endpoint found, using custom endpoint: %s", endpoint.URL)
152143
params.Endpoint = aws.String(endpoint.URL)
153144
params.Region = aws.String(s.endpointOptions.Region)
154145
return sts.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)
@@ -167,11 +158,9 @@ func (s *Route53EndpointResolver) ResolveEndpoint(ctx context.Context, params ro
167158
// If custom endpoint not found, return default endpoint for the service.
168159
endpoint, ok := s.endpoints[route53.ServiceID]
169160
if !ok {
170-
s.logger.Debug("Custom Route53 endpoint not found, using default endpoint")
171161
return route53.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)
172162
}
173163

174-
s.logger.Debugf("Custom Route53 endpoint found, using custom endpoint: %s", endpoint.URL)
175164
params.Endpoint = aws.String(endpoint.URL)
176165
params.Region = aws.String(s.endpointOptions.Region)
177166
return route53.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)
@@ -190,11 +179,9 @@ func (s *ServiceQuotasEndpointResolver) ResolveEndpoint(ctx context.Context, par
190179
// If custom endpoint not found, return default endpoint for the service.
191180
endpoint, ok := s.endpoints[servicequotas.ServiceID]
192181
if !ok {
193-
s.logger.Debug("Custom Service Quotas endpoint not found, using default endpoint")
194182
return servicequotas.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)
195183
}
196184

197-
s.logger.Debugf("Custom Service Quotas endpoint found, using custom endpoint: %s", endpoint.URL)
198185
params.Endpoint = aws.String(endpoint.URL)
199186
params.Region = aws.String(s.endpointOptions.Region)
200187
return servicequotas.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params)

pkg/asset/installconfig/aws/sessionv2.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type ConfigOptions []func(*config.LoadOptions) error
4646

4747
// getDefaultConfigOptions returns the default settings for config.LoadOptions.
4848
func getDefaultConfigOptions() ConfigOptions {
49-
return ConfigOptions{
49+
opts := ConfigOptions{
5050
config.WithRetryer(func() aws.Retryer {
5151
return retry.NewStandard(func(so *retry.StandardOptions) {
5252
so.MaxAttempts = RetryMaxAttempts
@@ -68,6 +68,14 @@ func getDefaultConfigOptions() ConfigOptions {
6868
awsmiddleware.AddUserAgentKeyValue(OpenShiftInstallerUserAgent, version.Raw),
6969
}),
7070
}
71+
72+
// Enable logging the HTTP request sent to the AWS service
73+
// including headers and body (if applicable).
74+
if _, ok := os.LookupEnv("OPENSHIFT_INSTALL_AWS_ENABLE_SDK_LOG"); ok {
75+
opts = append(opts, config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody))
76+
}
77+
78+
return opts
7179
}
7280

7381
// GetConfig returns an AWS config by checking credentials

0 commit comments

Comments
 (0)