From dc551e6c620de3cb068c1466ba84aee2c994264c Mon Sep 17 00:00:00 2001 From: Janusz Marcinkiewicz Date: Fri, 26 Jul 2024 09:44:10 +0200 Subject: [PATCH] ais: properly start listening on all extra pub interfaces Signed-off-by: Janusz Marcinkiewicz --- ais/htrun.go | 18 ++++++++++++------ ais/http.go | 12 ++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ais/htrun.go b/ais/htrun.go index e07f783e48..594564c981 100644 --- a/ais/htrun.go +++ b/ais/htrun.go @@ -307,6 +307,10 @@ func (h *htrun) initSnode(config *cmn.Config) { } // 1. pub net + + // the "hostname" field can be a single IP address or DNS hostname; + // it can also be a comma-separated list of IP addresses (or DNS hostnames), in which case the function + // returns pub = list[0] and extra = list[1:] pub, extra := multihome(config.HostNet.Hostname) if k8s.IsK8s() && config.HostNet.Hostname != "" { @@ -508,12 +512,14 @@ func (h *htrun) run(config *cmn.Config) error { if h.pubAddrAny(config) { ep = ":" + h.si.PubNet.Port } else if len(h.si.PubExtra) > 0 { - pubAddr2 := h.si.PubExtra[0] - debug.Assert(pubAddr2.Port == h.si.PubNet.Port) - g.netServ.pub2 = &netServer{muxers: g.netServ.pub.muxers, sndRcvBufSize: g.netServ.pub.sndRcvBufSize} - go func() { - _ = g.netServ.pub2.listen(pubAddr2.TCPEndpoint(), logger, tlsConf, config) - }() + for _, pubExtra := range h.si.PubExtra { + debug.Assert(pubExtra.Port == h.si.PubNet.Port, "expecting the same TCP port for all multi-home interfaces") + server := &netServer{muxers: g.netServ.pub.muxers, sndRcvBufSize: g.netServ.pub.sndRcvBufSize} + go func() { + _ = server.listen(pubExtra.TCPEndpoint(), logger, tlsConf, config) + }() + g.netServ.pubExtra = append(g.netServ.pubExtra, server) + } } return g.netServ.pub.listen(ep, logger, tlsConf, config) // stay here diff --git a/ais/http.go b/ais/http.go index 678757f92e..75b6cddb18 100644 --- a/ais/http.go +++ b/ais/http.go @@ -13,10 +13,10 @@ import ( type global struct { netServ struct { - pub *netServer - control *netServer - data *netServer - pub2 *netServer + pub *netServer + pubExtra []*netServer + control *netServer + data *netServer } client struct { control *http.Client // http client for intra-cluster comm @@ -94,8 +94,8 @@ func initDataClient(config *cmn.Config) { func shuthttp() { config := cmn.GCO.Get() g.netServ.pub.shutdown(config) - if g.netServ.pub2 != nil { - g.netServ.pub2.shutdown(config) + for _, server := range g.netServ.pubExtra { + server.shutdown(config) } if config.HostNet.UseIntraControl { g.netServ.control.shutdown(config)