Skip to content

Commit

Permalink
aws: Fix proxy dial to pick all proxies
Browse files Browse the repository at this point in the history
The current proxy dial function does not consider proxy
information provided in some environment variables like
http_proxy etc when checking if the service principal
provided is reachable. Adding a function that checks a few
env variables and dials the service to see if it is reachable.
  • Loading branch information
rna-afk committed Mar 30, 2022
1 parent af9c1b8 commit 96cddf2
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions pkg/asset/installconfig/aws/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net"
"net/http"
"net/url"
"sort"
"strings"
Expand All @@ -14,7 +15,6 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/route53"
"github.com/pkg/errors"
"golang.org/x/net/proxy"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation/field"
Expand Down Expand Up @@ -321,20 +321,12 @@ func validateEndpointAccessibility(endpointURL string) error {
if endpointURL == "e2e.local" {
return nil
}
URL, err := url.Parse(endpointURL)
_, err := url.Parse(endpointURL)
if err != nil {
return err
}
port := URL.Port()
if port == "" {
port = "https"
}
conn, err := proxy.Dial(context.Background(), "tcp", net.JoinHostPort(URL.Hostname(), port))
if err != nil {
return err
}
conn.Close()
return nil
_, err = http.Head(endpointURL)
return err
}

var requiredServices = []string{
Expand Down

0 comments on commit 96cddf2

Please sign in to comment.