Skip to content

Commit 1d50dff

Browse files
committed
OCPBUGS-77830: skip redirect when validating endpoint accessibility
The installer uses HTTP HEAD to validate if user-provided service endpoint URLs are reachable. However, in some cases, the request results in a redirect to AWS doc URL, which can causes install failure in disconnected environment. The users should not be required to open access to AWS docs to install. For example: $ curl --head https://sts.ap-southeast-1.amazonaws.com HTTP/1.1 302 Found Location: https://aws.amazon.com/iam
1 parent a6ba91c commit 1d50dff

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

pkg/asset/installconfig/aws/validation.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,18 @@ func validateEndpointAccessibility(endpointURL string) error {
864864
if _, err := url.Parse(endpointURL); err != nil {
865865
return fmt.Errorf("failed to parse service endpoint url: %w", err)
866866
}
867-
if _, err := http.Head(endpointURL); err != nil { //nolint:gosec
867+
868+
client := &http.Client{
869+
CheckRedirect: func(req *http.Request, via []*http.Request) error {
870+
return http.ErrUseLastResponse // Don't follow redirects
871+
},
872+
}
873+
resp, err := client.Head(endpointURL)
874+
if err != nil {
868875
return fmt.Errorf("failed to connect to service endpoint url: %w", err)
869876
}
877+
defer resp.Body.Close()
878+
870879
return nil
871880
}
872881

0 commit comments

Comments
 (0)