Skip to content

Commit

Permalink
Merge pull request noobaa#234 from jeniawhite/evgb-RpcFixes
Browse files Browse the repository at this point in the history
Additional checks in RPC configuration and print fixes
  • Loading branch information
jeniawhite authored Feb 17, 2020
2 parents 2b74fa0 + 8d221a2 commit 55827f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/nb/rpc_ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ func (c *RPCConnWS) ConnectUnderLock() error {
return nil
}
if c.State != "init" {
return fmt.Errorf("RPC: connection already closed %s %p", c.Address, c)
return fmt.Errorf("RPC: connection (%p) already closed %+v", c, c)
}

if c.ReconnectDelay != 0 {
logrus.Infof("RPC: Reconnect delay %s %s %p", c.ReconnectDelay, c.Address, c)
logrus.Infof("RPC: Reconnect (%p) delay %+v", c, c)
time.Sleep(c.ReconnectDelay)
}

logrus.Infof("RPC: Connecting websocket %s %p", c.Address, c)
logrus.Infof("RPC: Connecting websocket (%p) %+v", c, c)
ws, _, err := websocket.Dial(context.TODO(), c.Address, &websocket.DialOptions{HTTPClient: &c.RPC.HTTPClient})
if err != nil {
c.CloseUnderLock()
return err
}

logrus.Infof("RPC: Connected websocket %s %p", c.Address, c)
logrus.Infof("RPC: Connected websocket (%p) %+v", c, c)
ws.SetReadLimit(RPCMaxMessageSize)
c.WS = ws
c.State = "connected"
Expand All @@ -128,7 +128,7 @@ func (c *RPCConnWS) CloseUnderLock() {
if c.State == "closed" {
return
}
logrus.Errorf("RPC: closing connection %s %p", c.Address, c)
logrus.Errorf("RPC: closing connection (%p) %+v", c, c)
c.State = "closed"

// close the websocket
Expand Down
12 changes: 11 additions & 1 deletion pkg/system/phase3_connecting.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package system

import (
"fmt"
"net/url"
"path"
"strings"

nbv1 "github.com/noobaa/noobaa-operator/v2/pkg/apis/noobaa/v1alpha1"
Expand Down Expand Up @@ -141,8 +143,16 @@ func (r *Reconciler) InitNBClient() error {
})

} else {
addr := r.JoinSecret.StringData["mgmt_addr"]
u, err := url.Parse(addr)
// The URL's Parse method "may not necessarily return an error, due to parsing ambiguities"
if err != nil {
return err
}
u.Path = path.Join(u.Path, "rpc")
addr = u.String()
r.NBClient = nb.NewClient(&nb.SimpleRouter{
Address: fmt.Sprintf("%srpc", r.JoinSecret.StringData["mgmt_addr"]),
Address: addr,
})
}

Expand Down

0 comments on commit 55827f9

Please sign in to comment.