From: Tom Clegg Date: Fri, 1 Jul 2022 18:10:38 +0000 (-0400) Subject: 19166: Don't set up a reverse tunnel if we won't be advertising it. X-Git-Tag: 2.5.0~106^2~11 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/5e20c073d84304c3e84770bb7d89035bf1fb9626 19166: Don't set up a reverse tunnel if we won't be advertising it. Avoids wasting long-lived connections between crunch-run and controller. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go index df3abe6309..ff02257f2b 100644 --- a/lib/crunchrun/crunchrun.go +++ b/lib/crunchrun/crunchrun.go @@ -1905,32 +1905,26 @@ func (command) RunCommand(prog string, args []string, stdin io.Reader, stdout, s // not safe to run a gateway service without an auth // secret cr.CrunchLog.Printf("Not starting a gateway server (GatewayAuthSecret was not provided by dispatcher)") - } else if gwListen := os.Getenv("GatewayAddress"); gwListen == "" { - // dispatcher did not tell us which external IP - // address to advertise --> no gateway service - cr.CrunchLog.Printf("Not starting a gateway server (GatewayAddress was not provided by dispatcher)") } else { + gwListen := os.Getenv("GatewayAddress") cr.gateway = Gateway{ Address: gwListen, AuthSecret: gwAuthSecret, ContainerUUID: containerUUID, Target: cr.executor, Log: cr.CrunchLog, - ArvadosClient: cr.dispatcherClient, - UpdateTunnelURL: func(url string) { - if gwListen != "" { - // prefer connecting directly - return - } - // direct connection won't work, so we - // use the gateway_address field to - // indicate the internalURL of the - // controller process that has the - // current tunnel connection. + } + if gwListen == "" { + // Direct connection won't work, so we use the + // gateway_address field to indicate the + // internalURL of the controller process that + // has the current tunnel connection. + cr.gateway.ArvadosClient = cr.dispatcherClient + cr.gateway.UpdateTunnelURL = func(url string) { cr.gateway.Address = "tunnel " + url cr.DispatcherArvClient.Update("containers", containerUUID, arvadosclient.Dict{"container": arvadosclient.Dict{"gateway_address": cr.gateway.Address}}, nil) - }, + } } err = cr.gateway.Start() if err != nil {