Commit 5ba1b669 authored by Levin Zimmermann's avatar Levin Zimmermann

Client.URL: Fix incomplete URL if > 1 master nodes

Before this patch Client.URL didn't contain more than one master node.
This can be problematic in case we have a cluster with > 1 master nodes
and the printed master is a secondary master (which may be down). In
this case the user who trusts the "URL" attribute to connect to the
cluster won't succeed, because the primary master can't be reached.
parent 655c4cc3
......@@ -80,7 +80,7 @@ var _ zodb.IStorageDriver = (*Client)(nil)
//
// It will connect to master @masterAddr and identify with specified cluster name.
// Use Run to actually start running the node.
func NewClient(clusterName, masterAddrSlice []string, net xnet.Networker) *Client {
func NewClient(clusterName string, masterAddrSlice []string, net xnet.Networker) *Client {
c := &Client{
node: newMasteredNode(proto.CLIENT, clusterName, net, masterAddrSlice),
at0Ready: make(chan struct{}),
......@@ -542,7 +542,9 @@ func (c *Client) URL() string {
if strings.Contains(c.node.Net.Network(), "+tls") {
zurl += "s"
}
zurl += fmt.Sprintf("://%s/%s", c.node.MasterAddr, c.node.ClusterName)
zurl += fmt.Sprintf(
"://%s/%s", strings.Join(c.node.MasterAddrSlice, ","), c.node.ClusterName,
)
return zurl
}
......
......@@ -61,9 +61,9 @@ type Storage struct {
//
// The storage uses back as underlying backend for storing data.
// Use Run to actually start running the node.
func NewStorage(clusterName, masterAddr string, net xnet.Networker, back storage.Backend) *Storage {
func NewStorage(clusterName string, masterAddrSlice []string, net xnet.Networker, back storage.Backend) *Storage {
return &Storage{
node: newMasteredNode(proto.STORAGE, clusterName, net, masterAddr),
node: newMasteredNode(proto.STORAGE, clusterName, net, masterAddrSlice),
back: back,
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment