X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/004cf8a6b59ac10bf84e213309289e6138c48b7d..e3f324c979fe45803e2bd42aa8f6d715ea23edb5:/sdk/go/arvados/config.go diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go index 2965d5ecb0..4936aa270b 100644 --- a/sdk/go/arvados/config.go +++ b/sdk/go/arvados/config.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" "net/url" - "os" "git.curoverse.com/arvados.git/sdk/go/config" ) @@ -51,26 +50,24 @@ func (sc *Config) GetCluster(clusterID string) (*Cluster, error) { } } -type RequestLimits struct { - MaxItemsPerResponse int - MultiClusterRequestConcurrency int +type API struct { + MaxItemsPerResponse int + MaxRequestAmplification int + RequestTimeout Duration } type Cluster struct { - ClusterID string `json:"-"` - ManagementToken string - SystemRootToken string - Services Services - NodeProfiles map[string]NodeProfile - InstanceTypes InstanceTypeMap - CloudVMs CloudVMs - Dispatch Dispatch - HTTPRequestTimeout Duration - RemoteClusters map[string]RemoteCluster - PostgreSQL PostgreSQL - RequestLimits RequestLimits - Logging Logging - TLS TLS + ClusterID string `json:"-"` + ManagementToken string + SystemRootToken string + Services Services + InstanceTypes InstanceTypeMap + Containers ContainersConfig + RemoteClusters map[string]RemoteCluster + PostgreSQL PostgreSQL + API API + SystemLogs SystemLogs + TLS TLS } type Services struct { @@ -80,15 +77,16 @@ type Services struct { Keepbalance Service Keepproxy Service Keepstore Service - Keepweb Service Nodemanager Service RailsAPI Service + WebDAV Service Websocket Service - Workbench Service + Workbench1 Service + Workbench2 Service } type Service struct { - InternalURLs map[URL]ServiceInstance + InternalURLs map[URL]ServiceInstance `json:",omitempty"` ExternalURL URL } @@ -105,11 +103,16 @@ func (su *URL) UnmarshalText(text []byte) error { return err } +func (su URL) MarshalText() ([]byte, error) { + return []byte(fmt.Sprintf("%s", (*url.URL)(&su).String())), nil +} + type ServiceInstance struct{} -type Logging struct { - Level string - Format string +type SystemLogs struct { + LogLevel string + Format string + MaxRequestLogParamsSize int } type PostgreSQL struct { @@ -143,59 +146,29 @@ type InstanceType struct { Preemptible bool } -type Dispatch struct { - // PEM encoded SSH key (RSA, DSA, or ECDSA) able to log in to - // cloud VMs. - PrivateKey string - - // Max time for workers to come up before abandoning stale - // locks from previous run - StaleLockTimeout Duration - - // Interval between queue polls - PollInterval Duration - - // Interval between probes to each worker - ProbeInterval Duration - - // Maximum total worker probes per second - MaxProbesPerSecond int - - // Time before repeating SIGTERM when killing a container - TimeoutSignal Duration - - // Time to give up on SIGTERM and write off the worker - TimeoutTERM Duration +type ContainersConfig struct { + CloudVMs CloudVMsConfig + DispatchPrivateKey string + StaleLockTimeout Duration } -type CloudVMs struct { - // Shell command that exits zero IFF the VM is fully booted - // and ready to run containers, e.g., "mount | grep - // /encrypted-tmp" - BootProbeCommand string - - // Listening port (name or number) of SSH servers on worker - // VMs - SSHPort string +type CloudVMsConfig struct { + Enable bool - SyncInterval Duration - - // Maximum idle time before automatic shutdown - TimeoutIdle Duration - - // Maximum booting time before automatic shutdown - TimeoutBooting Duration - - // Maximum time with no successful probes before automatic shutdown - TimeoutProbe Duration - - // Time after shutdown to retry shutdown - TimeoutShutdown Duration - - // Maximum create/destroy-instance operations per second + BootProbeCommand string + ImageID string MaxCloudOpsPerSecond int - - ImageID string + MaxProbesPerSecond int + PollInterval Duration + ProbeInterval Duration + SSHPort string + SyncInterval Duration + TimeoutBooting Duration + TimeoutIdle Duration + TimeoutProbe Duration + TimeoutShutdown Duration + TimeoutSignal Duration + TimeoutTERM Duration Driver string DriverParameters json.RawMessage @@ -259,51 +232,16 @@ func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error { return nil } -// GetNodeProfile returns a NodeProfile for the given hostname. An -// error is returned if the appropriate configuration can't be -// determined (e.g., this does not appear to be a system node). If -// node is empty, use the OS-reported hostname. -func (cc *Cluster) GetNodeProfile(node string) (*NodeProfile, error) { - if node == "" { - hostname, err := os.Hostname() - if err != nil { - return nil, err - } - node = hostname - } - if cfg, ok := cc.NodeProfiles[node]; ok { - return &cfg, nil - } - // If node is not listed, but "*" gives a default system node - // config, use the default config. - if cfg, ok := cc.NodeProfiles["*"]; ok { - return &cfg, nil - } - return nil, fmt.Errorf("config does not provision host %q as a system node", node) -} - -type NodeProfile struct { - Controller SystemServiceInstance `json:"arvados-controller"` - Health SystemServiceInstance `json:"arvados-health"` - Keepbalance SystemServiceInstance `json:"keep-balance"` - Keepproxy SystemServiceInstance `json:"keepproxy"` - Keepstore SystemServiceInstance `json:"keepstore"` - Keepweb SystemServiceInstance `json:"keep-web"` - Nodemanager SystemServiceInstance `json:"arvados-node-manager"` - DispatchCloud SystemServiceInstance `json:"arvados-dispatch-cloud"` - RailsAPI SystemServiceInstance `json:"arvados-api-server"` - Websocket SystemServiceInstance `json:"arvados-ws"` - Workbench SystemServiceInstance `json:"arvados-workbench"` -} - type ServiceName string const ( ServiceNameRailsAPI ServiceName = "arvados-api-server" ServiceNameController ServiceName = "arvados-controller" ServiceNameDispatchCloud ServiceName = "arvados-dispatch-cloud" + ServiceNameHealth ServiceName = "arvados-health" ServiceNameNodemanager ServiceName = "arvados-node-manager" - ServiceNameWorkbench ServiceName = "arvados-workbench" + ServiceNameWorkbench1 ServiceName = "arvados-workbench1" + ServiceNameWorkbench2 ServiceName = "arvados-workbench2" ServiceNameWebsocket ServiceName = "arvados-ws" ServiceNameKeepbalance ServiceName = "keep-balance" ServiceNameKeepweb ServiceName = "keep-web" @@ -313,39 +251,21 @@ const ( // ServicePorts returns the configured listening address (or "" if // disabled) for each service on the node. -func (np *NodeProfile) ServicePorts() map[ServiceName]string { - return map[ServiceName]string{ - ServiceNameRailsAPI: np.RailsAPI.Listen, - ServiceNameController: np.Controller.Listen, - ServiceNameDispatchCloud: np.DispatchCloud.Listen, - ServiceNameNodemanager: np.Nodemanager.Listen, - ServiceNameWorkbench: np.Workbench.Listen, - ServiceNameWebsocket: np.Websocket.Listen, - ServiceNameKeepbalance: np.Keepbalance.Listen, - ServiceNameKeepweb: np.Keepweb.Listen, - ServiceNameKeepproxy: np.Keepproxy.Listen, - ServiceNameKeepstore: np.Keepstore.Listen, - } -} - -func (h RequestLimits) GetMultiClusterRequestConcurrency() int { - if h.MultiClusterRequestConcurrency == 0 { - return 4 - } - return h.MultiClusterRequestConcurrency -} - -func (h RequestLimits) GetMaxItemsPerResponse() int { - if h.MaxItemsPerResponse == 0 { - return 1000 +func (svcs Services) Map() map[ServiceName]Service { + return map[ServiceName]Service{ + ServiceNameRailsAPI: svcs.RailsAPI, + ServiceNameController: svcs.Controller, + ServiceNameDispatchCloud: svcs.DispatchCloud, + ServiceNameHealth: svcs.Health, + ServiceNameNodemanager: svcs.Nodemanager, + ServiceNameWorkbench1: svcs.Workbench1, + ServiceNameWorkbench2: svcs.Workbench2, + ServiceNameWebsocket: svcs.Websocket, + ServiceNameKeepbalance: svcs.Keepbalance, + ServiceNameKeepweb: svcs.WebDAV, + ServiceNameKeepproxy: svcs.Keepproxy, + ServiceNameKeepstore: svcs.Keepstore, } - return h.MaxItemsPerResponse -} - -type SystemServiceInstance struct { - Listen string - TLS bool - Insecure bool } type TLS struct {