From e31b0b47efc6636cc349f351f3db4ea73fa46816 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Tue, 6 Aug 2019 11:14:28 +0200 Subject: [PATCH] executor: listen on wildcard address Since the current logic is to use the first available private ip address as the advertized address we have to listen on wildcard since a different host provided in web.ListenAddress will make the executor unreachable. In future improve this to let the user to manually define the bind and the advertized address (perhaps using go-sockaddr templates like done by consul) to also support nat between the schedulers and the executors. --- internal/services/executor/executor.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/services/executor/executor.go b/internal/services/executor/executor.go index 41909fb..0297dae 100644 --- a/internal/services/executor/executor.go +++ b/internal/services/executor/executor.go @@ -1308,6 +1308,7 @@ type Executor struct { id string runningTasks *runningTasks driver driver.Driver + listenAddress string listenURL string dynamic bool } @@ -1348,6 +1349,8 @@ func NewExecutor(c *config.Executor) (*Executor, error) { e.id = id + // TODO(sgotti) now the first available private ip will be used and the executor will bind to the wildcard address + // improve this to let the user define the bind and the advertize address addr, err := sockaddr.GetPrivateIP() if err != nil { return nil, errors.Errorf("cannot discover executor listen address: %w", err) @@ -1366,6 +1369,8 @@ func NewExecutor(c *config.Executor) (*Executor, error) { u.Host = net.JoinHostPort(addr, port) e.listenURL = u.String() + e.listenAddress = fmt.Sprintf(":%s", port) + var d driver.Driver switch c.Driver.Type { case config.DriverTypeDocker: @@ -1413,7 +1418,7 @@ func (e *Executor) Run(ctx context.Context) error { go e.handleTasks(ctx, ch) httpServer := http.Server{ - Addr: e.c.Web.ListenAddress, + Addr: e.listenAddress, Handler: apirouter, } lerrCh := make(chan error)