config

package
v0.0.0-...-3511abf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BasicAuthZType is the default authz string id.
	BasicAuthZType = "basic"
	RBACAuthZType  = "rbac"
)

Authz string ids.

View Source
const (
	// DefaultSchedulingPriority is the default resource manager priority.
	DefaultSchedulingPriority = 42

	// FairShareScheduling schedules tasks proportional to the available resources.
	FairShareScheduling = "fair_share"
	// PriorityScheduling schedules tasks based on their priority.
	PriorityScheduling = "priority"
	// RoundRobinScheduling schedules tasks based on the order in which they arrive.
	RoundRobinScheduling = "round_robin"
)
View Source
const (
	KubernetesDefaultPriority = 50
)

KubernetesDefaultPriority is the default K8 resource manager priority.

View Source
const PreemptionScheduler = "preemption"

PreemptionScheduler is the name of the preemption scheduler for k8. HACK(Brad): Here because circular imports; Kubernetes probably needs its own configuration package.

Variables

View Source
var (
	DefaultSegmentMasterKey = ""
	DefaultSegmentWebUIKey  = ""
)

These are package-level variables so that they can be set at link time. WARN: if you move them to a different package, you need to change the linked path in the make file and CI.

Functions

func GetCertPEM

func GetCertPEM(cert *tls.Certificate) []byte

GetCertPEM returns the PEM-encoded certificate.

func ReadPriority

func ReadPriority(rpName string, jobConf interface{}) int

ReadPriority resolves the priority value for a job.

func ReadRMPreemptionStatus

func ReadRMPreemptionStatus(rpName string) bool

ReadRMPreemptionStatus resolves the preemption status for a resource manager. TODO(Brad): Move these to a resource pool level API.

func ReadWeight

func ReadWeight(rpName string, jobConf interface{}) float64

ReadWeight resolves the weight value for a job.

func RegisterAuthZType

func RegisterAuthZType(authzType string)

RegisterAuthZType adds new known authz type.

func SetMasterConfig

func SetMasterConfig(aConfig *Config)

SetMasterConfig sets the master config singleton.

Types

type AgentResourceManagerConfig

type AgentResourceManagerConfig struct {
	Scheduler                  *SchedulerConfig `json:"scheduler"`
	DefaultAuxResourcePool     string           `json:"default_aux_resource_pool"`
	DefaultComputeResourcePool string           `json:"default_compute_resource_pool"`
	NoDefaultResourcePools     bool             `json:"no_default_resource_pools"`
	// Deprecated: use DefaultAuxResourcePool instead.
	DefaultCPUResourcePool string `json:"default_cpu_resource_pool,omitempty"`
	// Deprecated: use DefaultComputeResourcePool instead.
	DefaultGPUResourcePool string `json:"default_gpu_resource_pool,omitempty"`

	RequireAuthentication bool   `json:"require_authentication"`
	ClientCA              string `json:"client_ca"`
}

AgentResourceManagerConfig hosts configuration fields for the determined resource manager.

func (*AgentResourceManagerConfig) UnmarshalJSON

func (a *AgentResourceManagerConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (AgentResourceManagerConfig) Validate

func (a AgentResourceManagerConfig) Validate() []error

Validate implements the check.Validatable interface.

type AssignWorkspaceCreatorConfig

type AssignWorkspaceCreatorConfig struct {
	Enabled bool `json:"enabled"`
	RoleID  int  `json:"role_id"`
}

AssignWorkspaceCreatorConfig configures behavior of assigning a role on workspace creation.

func (AssignWorkspaceCreatorConfig) Validate

func (a AssignWorkspaceCreatorConfig) Validate() []error

Validate the RoleID of the config.

type AuthZConfig

type AuthZConfig struct {
	Type          string  `json:"type"`
	FallbackType  *string `json:"fallback"`
	RBACUIEnabled *bool   `json:"rbac_ui_enabled"`
	// Removed: this option is removed and will not have any effect.
	StrictNTSCEnabled      bool                         `json:"_strict_ntsc_enabled"`
	AssignWorkspaceCreator AssignWorkspaceCreatorConfig `json:"workspace_creator_assign_role"`
	StrictJobQueueControl  bool                         `json:"strict_job_queue_control"`
}

AuthZConfig is a authz-related section of master config.

func DefaultAuthZConfig

func DefaultAuthZConfig() *AuthZConfig

DefaultAuthZConfig returns default authz config.

func GetAuthZConfig

func GetAuthZConfig() AuthZConfig

GetAuthZConfig returns current global authz config.

func (AuthZConfig) IsRBACEnabled

func (c AuthZConfig) IsRBACEnabled() bool

IsRBACEnabled returns if the authz config type is using the RBAC implementation and will attempt to use Fallback and Default types if necessary.

func (AuthZConfig) IsRBACUIEnabled

func (c AuthZConfig) IsRBACUIEnabled() bool

IsRBACUIEnabled returns if the feature flag RBAC should be enabled.

func (*AuthZConfig) Validate

func (c *AuthZConfig) Validate() []error

Validate the authz config.

type CacheConfig

type CacheConfig struct {
	CacheDir string `json:"cache_dir"`
}

CacheConfig is the configuration for file cache.

type Config

type Config struct {
	ConfigFile            string                            `json:"config_file"`
	Log                   logger.Config                     `json:"log"`
	DB                    DBConfig                          `json:"db"`
	TensorBoardTimeout    int                               `json:"tensorboard_timeout"`
	NotebookTimeout       *int                              `json:"notebook_timeout"`
	Security              SecurityConfig                    `json:"security"`
	CheckpointStorage     expconf.CheckpointStorageConfig   `json:"checkpoint_storage"`
	TaskContainerDefaults model.TaskContainerDefaultsConfig `json:"task_container_defaults"`
	Port                  int                               `json:"port"`
	Root                  string                            `json:"root"`
	Telemetry             config.TelemetryConfig            `json:"telemetry"`
	EnableCors            bool                              `json:"enable_cors"`
	LaunchError           bool                              `json:"launch_error"`
	ClusterName           string                            `json:"cluster_name"`
	Logging               model.LoggingConfig               `json:"logging"`
	Observability         ObservabilityConfig               `json:"observability"`
	Cache                 CacheConfig                       `json:"cache"`
	Webhooks              WebhooksConfig                    `json:"webhooks"`
	FeatureSwitches       []string                          `json:"feature_switches"`
	ReservedPorts         []int                             `json:"reserved_ports"`
	ResourceConfig

	// Internal contains "hidden" useful debugging configurations.
	InternalConfig InternalConfig `json:"__internal"`
}

Config is the configuration of the master.

It is populated, in the following order, by the master configuration file, environment variables and command line arguments.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration of the master.

func GetMasterConfig

func GetMasterConfig() *Config

GetMasterConfig returns reference to the master config singleton.

func (*Config) Deprecations

func (c *Config) Deprecations() (errs []error)

Deprecations describe fields which were recently or will soon be removed.

func (Config) Printable

func (c Config) Printable() ([]byte, error)

Printable returns a printable string.

func (*Config) Resolve

func (c *Config) Resolve() error

Resolve resolves the values in the configuration.

type DBConfig

type DBConfig struct {
	User        string `json:"user"`
	Password    string `json:"password"`
	Migrations  string `json:"migrations"`
	Host        string `json:"host"`
	Port        string `json:"port"`
	Name        string `json:"name"`
	SSLMode     string `json:"ssl_mode"`
	SSLRootCert string `json:"ssl_root_cert"`
}

DBConfig hosts configuration fields of the database.

func DefaultDBConfig

func DefaultDBConfig() *DBConfig

DefaultDBConfig returns the default configuration of the database.

type ExperimentConfigPatch

type ExperimentConfigPatch struct {
	Name *string `json:"name,omitempty"`
}

ExperimentConfigPatch is the updatedble fields for patching an experiment.

type FairShareSchedulerConfig

type FairShareSchedulerConfig struct{}

FairShareSchedulerConfig holds configurations for the fair share scheduler.

type FluentConfig

type FluentConfig struct {
	Image string `json:"image"`
	UID   int    `json:"uid"`
	GID   int    `json:"gid"`
}

FluentConfig stores k8s-configurable Fluent Bit-related options.

type InternalConfig

type InternalConfig struct {
	AuditLoggingEnabled bool                   `json:"audit_logging_enabled"`
	ExternalSessions    model.ExternalSessions `json:"external_sessions"`
	ProxiedServers      []ProxiedServerConfig  `json:"proxied_servers"`
}

InternalConfig is the configuration for internal knobs.

func (*InternalConfig) Validate

func (i *InternalConfig) Validate() []error

Validate implements the check.Validatable interface.

type KubernetesResourceManagerConfig

type KubernetesResourceManagerConfig struct {
	Namespace string `json:"namespace"`

	// Deprecated: this can be per resource pool now on taskContainerDefaults.
	// This will always be the same as global
	// task_container_defaults.kubernetes.max_slots_per_pod so use that.
	MaxSlotsPerPod *int `json:"max_slots_per_pod"`

	MasterServiceName        string                  `json:"master_service_name"`
	LeaveKubernetesResources bool                    `json:"leave_kubernetes_resources"`
	DefaultScheduler         string                  `json:"default_scheduler"`
	SlotType                 device.Type             `json:"slot_type"`
	SlotResourceRequests     PodSlotResourceRequests `json:"slot_resource_requests"`
	// deprecated, no longer in use.
	Fluent     FluentConfig `json:"fluent"`
	CredsDir   string       `json:"_creds_dir,omitempty"`
	MasterIP   string       `json:"_master_ip,omitempty"`
	MasterPort int32        `json:"_master_port,omitempty"`

	DefaultAuxResourcePool     string `json:"default_aux_resource_pool"`
	DefaultComputeResourcePool string `json:"default_compute_resource_pool"`
	NoDefaultResourcePools     bool   `json:"no_default_resource_pools"`
}

KubernetesResourceManagerConfig hosts configuration fields for the kubernetes resource manager.

func (*KubernetesResourceManagerConfig) GetPreemption

func (k *KubernetesResourceManagerConfig) GetPreemption() bool

GetPreemption returns whether the RM is set to preempt.

func (*KubernetesResourceManagerConfig) UnmarshalJSON

func (k *KubernetesResourceManagerConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (KubernetesResourceManagerConfig) Validate

func (k KubernetesResourceManagerConfig) Validate() []error

Validate implements the check.Validatable interface.

type ObservabilityConfig

type ObservabilityConfig struct {
	EnablePrometheus bool `json:"enable_prometheus"`
}

ObservabilityConfig is the configuration for observability metrics.

type PodSlotResourceRequests

type PodSlotResourceRequests struct {
	CPU float32 `json:"cpu"`
}

PodSlotResourceRequests contains the per-slot container requests.

type PrioritySchedulerConfig

type PrioritySchedulerConfig struct {
	Preemption      bool `json:"preemption"`
	DefaultPriority *int `json:"default_priority"`
}

PrioritySchedulerConfig holds the configurations for the priority scheduler.

func (PrioritySchedulerConfig) Validate

func (p PrioritySchedulerConfig) Validate() []error

Validate implements the check.Validatable interface.

type ProxiedServerConfig

type ProxiedServerConfig struct {
	// Prefix is the path prefix to match for this proxy.
	PathPrefix string `json:"path_prefix"`
	// Destination is the URL to proxy to.
	Destination string `json:"destination"`
}

ProxiedServerConfig is the configuration for a internal proxied server.

func (*ProxiedServerConfig) Validate

func (p *ProxiedServerConfig) Validate() []error

Validate implements the check.Validatable interface.

type ResourceConfig

type ResourceConfig struct {
	ResourceManager *ResourceManagerConfig `json:"resource_manager"`
	ResourcePools   []ResourcePoolConfig   `json:"resource_pools"`
}

ResourceConfig hosts configuration fields of the resource manager and resource pools.

func DefaultResourceConfig

func DefaultResourceConfig() *ResourceConfig

DefaultResourceConfig returns the default resource configuration.

func (*ResourceConfig) ResolveResource

func (r *ResourceConfig) ResolveResource() error

ResolveResource resolves the config.

func (ResourceConfig) Validate

func (r ResourceConfig) Validate() []error

Validate implements the check.Validatable interface.

type ResourceManagerConfig

type ResourceManagerConfig struct {
	AgentRM      *AgentResourceManagerConfig      `union:"type,agent" json:"-"`
	KubernetesRM *KubernetesResourceManagerConfig `union:"type,kubernetes" json:"-"`
}

ResourceManagerConfig hosts configuration fields for the resource manager.

func (ResourceManagerConfig) MarshalJSON

func (r ResourceManagerConfig) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*ResourceManagerConfig) UnmarshalJSON

func (r *ResourceManagerConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type ResourcePoolConfig

type ResourcePoolConfig struct {
	PoolName                 string                             `json:"pool_name"`
	Description              string                             `json:"description"`
	Provider                 *provconfig.Config                 `json:"provider"`
	Scheduler                *SchedulerConfig                   `json:"scheduler,omitempty"`
	MaxAuxContainersPerAgent int                                `json:"max_aux_containers_per_agent"`
	TaskContainerDefaults    *model.TaskContainerDefaultsConfig `json:"task_container_defaults"`
	// AgentReattachEnabled defines if master & agent try to recover
	// running containers after a clean restart.
	AgentReattachEnabled bool `json:"agent_reattach_enabled"`
	// AgentReconnectWait define the time master will wait for agent
	// before abandoning it.
	AgentReconnectWait model.Duration `json:"agent_reconnect_wait"`

	// If empty, will behave as if the value is resource_manager.namespace,
	// which in most cases will be the namespace the helm deployment is in.
	KubernetesNamespace string `json:"kubernetes_namespace"`

	// Deprecated: Use MaxAuxContainersPerAgent instead.
	MaxCPUContainersPerAgent int `json:"max_cpu_containers_per_agent,omitempty"`
}

ResourcePoolConfig hosts the configuration for a resource pool.

func (ResourcePoolConfig) Printable

func (r ResourcePoolConfig) Printable() ResourcePoolConfig

Printable returns a printable object.

func (*ResourcePoolConfig) UnmarshalJSON

func (r *ResourcePoolConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (ResourcePoolConfig) Validate

func (r ResourcePoolConfig) Validate() []error

Validate implements the check.Validatable interface.

type RoundRobinSchedulerConfig

type RoundRobinSchedulerConfig struct{}

RoundRobinSchedulerConfig holds the configurations for the round robing scheduler.

type SSHConfig

type SSHConfig struct {
	RsaKeySize int `json:"rsa_key_size"`
}

SSHConfig is the configuration setting for SSH.

func (*SSHConfig) Validate

func (t *SSHConfig) Validate() []error

Validate implements the check.Validatable interface.

type SchedulerConfig

type SchedulerConfig struct {
	FairShare              *FairShareSchedulerConfig  `union:"type,fair_share" json:"-"`
	Priority               *PrioritySchedulerConfig   `union:"type,priority" json:"-"`
	RoundRobin             *RoundRobinSchedulerConfig `union:"type,round_robin" json:"-"`
	FittingPolicy          string                     `json:"fitting_policy"`
	AllowHeterogeneousFits bool                       `json:"allow_heterogeneous_fits"`
}

SchedulerConfig holds the configurations for scheduling policies.

func DefaultSchedulerConfig

func DefaultSchedulerConfig() *SchedulerConfig

DefaultSchedulerConfig returns the default fair share configuration for the scheduler.

func (*SchedulerConfig) GetPreemption

func (s *SchedulerConfig) GetPreemption() bool

GetPreemption returns whether the scheduler is set to preempt.

func (*SchedulerConfig) GetType

func (s *SchedulerConfig) GetType() string

GetType returns the type of scheduler that is configured.

func (SchedulerConfig) MarshalJSON

func (s SchedulerConfig) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*SchedulerConfig) UnmarshalJSON

func (s *SchedulerConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (SchedulerConfig) Validate

func (s SchedulerConfig) Validate() []error

Validate implements the check.Validatable interface.

type SecurityConfig

type SecurityConfig struct {
	DefaultTask model.AgentUserGroup `json:"default_task"`
	TLS         TLSConfig            `json:"tls"`
	SSH         SSHConfig            `json:"ssh"`
	AuthZ       AuthZConfig          `json:"authz"`
}

SecurityConfig is the security configuration for the master.

type TLSConfig

type TLSConfig struct {
	Cert string `json:"cert"`
	Key  string `json:"key"`
}

TLSConfig is the configuration for setting up serving over TLS.

func (*TLSConfig) Enabled

func (t *TLSConfig) Enabled() bool

Enabled returns whether this configuration makes it possible to enable TLS.

func (*TLSConfig) ReadCertificate

func (t *TLSConfig) ReadCertificate() (*tls.Certificate, error)

ReadCertificate returns the certificate described by this configuration (nil if it does not allow TLS to be enabled).

func (*TLSConfig) Validate

func (t *TLSConfig) Validate() []error

Validate implements the check.Validatable interface.

type WebhooksConfig

type WebhooksConfig struct {
	BaseURL    string `json:"base_url"`
	SigningKey string `json:"signing_key"`
}

WebhooksConfig hosts configuration fields for webhook functionality.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL