17212: Propagate -listen-host to postgresql and passenger.
authorTom Clegg <tom@curii.com>
Thu, 4 Feb 2021 19:55:25 +0000 (14:55 -0500)
committerTom Clegg <tom@curii.com>
Thu, 4 Feb 2021 19:55:25 +0000 (14:55 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/boot/nginx.go
lib/boot/passenger.go
lib/boot/postgresql.go
lib/boot/supervisor.go

index d14d0515201b0b3237ea56059101d78695e37769..dc4aebd528d4bf3f6c8d43c359efb8b51ed6b73a 100644 (file)
@@ -53,12 +53,12 @@ func (runNginx) Run(ctx context.Context, fail func(error), super *Supervisor) er
                {"WORKBENCH1", super.cluster.Services.Workbench1},
                {"WS", super.cluster.Services.Websocket},
        } {
-               port, err := internalPort(cmpt.svc)
+               host, port, err := internalPort(cmpt.svc)
                if err != nil {
                        return fmt.Errorf("%s internal port: %w (%v)", cmpt.varname, err, cmpt.svc)
                }
-               if ok, err := addrIsLocal(net.JoinHostPort(super.ListenHost, port)); !ok || err != nil {
-                       return fmt.Errorf("urlIsLocal() failed for host %q port %q: %v", super.ListenHost, port, err)
+               if ok, err := addrIsLocal(net.JoinHostPort(host, port)); !ok || err != nil {
+                       return fmt.Errorf("urlIsLocal() failed for host %q port %q: %v", host, port, err)
                }
                vars[cmpt.varname+"PORT"] = port
 
index 4203939975618f9283b462866c1f16b14d16b5dd..0340ebc8c64272944cf202fd2ec2c5c9f0788f32 100644 (file)
@@ -102,7 +102,7 @@ func (runner runPassenger) Run(ctx context.Context, fail func(error), super *Sup
        if err != nil {
                return err
        }
-       port, err := internalPort(runner.svc)
+       host, port, err := internalPort(runner.svc)
        if err != nil {
                return fmt.Errorf("bug: no internalPort for %q: %v (%#v)", runner, err, runner.svc)
        }
@@ -130,7 +130,9 @@ func (runner runPassenger) Run(ctx context.Context, fail func(error), super *Sup
                cmdline := []string{
                        "bundle", "exec",
                        "passenger", "start",
-                       "-p", port,
+                       "--address", host,
+                       "--port", port,
+                       "--log-file", "/dev/stderr",
                        "--log-level", loglevel,
                        "--no-friendly-error-pages",
                        "--disable-anonymous-telemetry",
index 4ed7603d2a55689a298041286dddca5f09643b97..d105b0b62342b4defc60838e14accd9f38ce9ed8 100644 (file)
@@ -113,6 +113,7 @@ func (runPostgreSQL) Run(ctx context.Context, fail func(error), super *Superviso
                        "-l",          // enable ssl
                        "-D", datadir, // data dir
                        "-k", datadir, // socket dir
+                       "-h", super.cluster.PostgreSQL.Connection["host"],
                        "-p", super.cluster.PostgreSQL.Connection["port"],
                }
                opts := runOptions{}
index 77504deb057f05a39d572679f3d0f55d5a926dff..961ed55de37e1f7fb5d165edfa63f562689ceeff 100644 (file)
@@ -734,7 +734,7 @@ func (super *Supervisor) autofillConfig(cfg *arvados.Config) error {
        if super.OwnTemporaryDatabase {
                cluster.PostgreSQL.Connection = arvados.PostgreSQLConnection{
                        "client_encoding": "utf8",
-                       "host":            "localhost",
+                       "host":            super.ListenHost,
                        "port":            nextPort(super.ListenHost),
                        "dbname":          "arvados_test",
                        "user":            "arvados",
@@ -768,21 +768,23 @@ func randomHexString(chars int) string {
        return fmt.Sprintf("%x", b)
 }
 
-func internalPort(svc arvados.Service) (string, error) {
+func internalPort(svc arvados.Service) (host, port string, err error) {
        if len(svc.InternalURLs) > 1 {
-               return "", errors.New("internalPort() doesn't work with multiple InternalURLs")
+               return "", "", errors.New("internalPort() doesn't work with multiple InternalURLs")
        }
        for u := range svc.InternalURLs {
                u := url.URL(u)
-               if p := u.Port(); p != "" {
-                       return p, nil
-               } else if u.Scheme == "https" || u.Scheme == "ws" {
-                       return "443", nil
-               } else {
-                       return "80", nil
+               host, port = u.Hostname(), u.Port()
+               switch {
+               case port != "":
+               case u.Scheme == "https", u.Scheme == "ws":
+                       port = "443"
+               default:
+                       port = "80"
                }
+               return
        }
-       return "", fmt.Errorf("service has no InternalURLs")
+       return "", "", fmt.Errorf("service has no InternalURLs")
 }
 
 func externalPort(svc arvados.Service) (string, error) {