Merge branch '17170-container-shell'
[arvados.git] / lib / boot / supervisor.go
index c75e7f146e3ce2b2734575804aa25c477839efdc..961ed55de37e1f7fb5d165edfa63f562689ceeff 100644 (file)
@@ -443,7 +443,7 @@ func (super *Supervisor) setupRubyEnv() error {
                cmd.Env = super.environ
                buf, err := cmd.Output() // /var/lib/arvados/.gem/ruby/2.5.0/bin:...
                if err != nil || len(buf) == 0 {
-                       return fmt.Errorf("gem env gempath: %v", err)
+                       return fmt.Errorf("gem env gempath: %w", err)
                }
                gempath := string(bytes.Split(buf, []byte{':'})[0])
                super.prependEnv("PATH", gempath+"/bin:")
@@ -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) {