Skip to content

Commit 8b4c52b

Browse files
committed
universe: don't resolve universe address
We need to pass in the hostname when connecting to a universe server, otherwise TLS SNI will not work correctly with ingress controllers.
1 parent 697a6b7 commit 8b4c52b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

universe_rpc_registrar.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ func CheckFederationServer(localRuntimeID int64, connectTimeout time.Duration,
138138
srvrLog.Debugf("Attempting to connect to federation server %v",
139139
server.HostStr())
140140

141+
// Resolving the address first to ensure that we can connect to it.
142+
resolvedAddr, err := server.Addr()
143+
if err != nil {
144+
return fmt.Errorf("error resolving server address %v: %w",
145+
server.HostStr(), err)
146+
}
147+
148+
srvrLog.Debugf("Resolved federation server address: %v",
149+
resolvedAddr.String())
150+
141151
conn, err := ConnectUniverse(server)
142152
if err != nil {
143153
return fmt.Errorf("error connecting to server %v: %w",
@@ -175,8 +185,7 @@ type universeClientConn struct {
175185
func ConnectUniverse(
176186
serverAddr universe.ServerAddr) (*universeClientConn, error) {
177187

178-
// TODO(roasbeef): all info is authenticated, but also want to allow
179-
// brontide connect as well, can avoid TLS certs
188+
uniAddr := serverAddr.HostStr()
180189
creds := credentials.NewTLS(&tls.Config{
181190
InsecureSkipVerify: true,
182191
})
@@ -187,12 +196,8 @@ func ConnectUniverse(
187196
grpc.WithDefaultCallOptions(MaxMsgReceiveSize),
188197
}
189198

190-
uniAddr, err := serverAddr.Addr()
191-
if err != nil {
192-
return nil, err
193-
}
194-
195-
rawConn, err := grpc.Dial(uniAddr.String(), opts...)
199+
srvrLog.Infof("Connecting to Universe server at %s", uniAddr)
200+
rawConn, err := grpc.NewClient(uniAddr, opts...)
196201
if err != nil {
197202
return nil, fmt.Errorf("unable to connect to RPC server: "+
198203
"%w", err)

0 commit comments

Comments
 (0)