X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/41305b5ac71cc9a306dc654c42c11ffcc4258a47..2820d5bd17fcaa7b9d2f6e14bf0f1820b7ea8107:/lib/boot/supervisor.go diff --git a/lib/boot/supervisor.go b/lib/boot/supervisor.go index 838808df58..2c89ccdb00 100644 --- a/lib/boot/supervisor.go +++ b/lib/boot/supervisor.go @@ -42,6 +42,7 @@ type Supervisor struct { ClusterType string // e.g., production ListenHost string // e.g., localhost ControllerAddr string // e.g., 127.0.0.1:8000 + NoWorkbench1 bool OwnTemporaryDatabase bool Stderr io.Writer @@ -63,6 +64,8 @@ type Supervisor struct { environ []string // for child processes } +func (super *Supervisor) Cluster() *arvados.Cluster { return super.cluster } + func (super *Supervisor) Start(ctx context.Context, cfg *arvados.Config, cfgPath string) { super.ctx, super.cancel = context.WithCancel(ctx) super.done = make(chan struct{}) @@ -242,15 +245,19 @@ func (super *Supervisor) run(cfg *arvados.Config) error { runGoProgram{src: "services/arv-git-httpd", svc: super.cluster.Services.GitHTTP}, runGoProgram{src: "services/health", svc: super.cluster.Services.Health}, runGoProgram{src: "services/keepproxy", svc: super.cluster.Services.Keepproxy, depends: []supervisedTask{runPassenger{src: "services/api"}}}, - runGoProgram{src: "services/keepstore", svc: super.cluster.Services.Keepstore}, + runServiceCommand{name: "keepstore", svc: super.cluster.Services.Keepstore}, runGoProgram{src: "services/keep-web", svc: super.cluster.Services.WebDAV}, runServiceCommand{name: "ws", svc: super.cluster.Services.Websocket, depends: []supervisedTask{seedDatabase{}}}, installPassenger{src: "services/api"}, runPassenger{src: "services/api", varlibdir: "railsapi", svc: super.cluster.Services.RailsAPI, depends: []supervisedTask{createCertificates{}, seedDatabase{}, installPassenger{src: "services/api"}}}, - installPassenger{src: "apps/workbench", depends: []supervisedTask{seedDatabase{}}}, // dependency ensures workbench doesn't delay api install/startup - runPassenger{src: "apps/workbench", varlibdir: "workbench1", svc: super.cluster.Services.Workbench1, depends: []supervisedTask{installPassenger{src: "apps/workbench"}}}, seedDatabase{}, } + if !super.NoWorkbench1 { + tasks = append(tasks, + installPassenger{src: "apps/workbench", depends: []supervisedTask{seedDatabase{}}}, // dependency ensures workbench doesn't delay api install/startup + runPassenger{src: "apps/workbench", varlibdir: "workbench1", svc: super.cluster.Services.Workbench1, depends: []supervisedTask{installPassenger{src: "apps/workbench"}}}, + ) + } if super.ClusterType != "test" { tasks = append(tasks, runServiceCommand{name: "dispatch-cloud", svc: super.cluster.Services.DispatchCloud}, @@ -441,7 +448,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:") @@ -676,6 +683,14 @@ func (super *Supervisor) autofillConfig(cfg *arvados.Config) error { svc.ExternalURL = arvados.URL{Scheme: "wss", Host: fmt.Sprintf("%s:%s", super.ListenHost, nextPort(super.ListenHost)), Path: "/websocket"} } } + if super.NoWorkbench1 && svc == &cluster.Services.Workbench1 { + // When workbench1 is disabled, it gets an + // ExternalURL (so we have a valid listening + // port to write in our Nginx config) but no + // InternalURLs (so health checker doesn't + // complain). + continue + } if len(svc.InternalURLs) == 0 { svc.InternalURLs = map[arvados.URL]arvados.ServiceInstance{ {Scheme: "http", Host: fmt.Sprintf("%s:%s", super.ListenHost, nextPort(super.ListenHost)), Path: "/"}: {}, @@ -726,13 +741,23 @@ func (super *Supervisor) autofillConfig(cfg *arvados.Config) error { AccessViaHosts: map[arvados.URL]arvados.VolumeAccess{ url: {}, }, + StorageClasses: map[string]bool{ + "default": true, + "foo": true, + "bar": true, + }, } } + cluster.StorageClasses = map[string]arvados.StorageClassConfig{ + "default": {Default: true}, + "foo": {}, + "bar": {}, + } } 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", @@ -766,21 +791,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) {