conf

package
v0.0.0-...-ddb491b Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfig

func NewConfig[C any]() C

Create a new configuration from the default config json file.

This will read two files:

  • /etc/config/conf.json
  • /etc/secrets/secrets.json

The values read from secrets.json will override the values in conf.json

Types

type APIConfig

type APIConfig struct {
	// The port to expose the API on.
	Port int `json:"port"`
}

Configuration for the api port.

type CinderSchedulerConfig

type CinderSchedulerConfig struct {
	// Pipelines in this scheduler.
	Pipelines []CinderSchedulerPipelineConfig `json:"pipelines"`
}

type CinderSchedulerPipelineConfig

type CinderSchedulerPipelineConfig struct {
	// Scheduler step plugins by their name.
	Plugins []SchedulerStepConfig `json:"plugins"`

	// The name of this scheduler pipeline.
	// The name is used to distinguish and route between multiple pipelines.
	Name string `json:"name"`
}

type Config

type Config interface {
	GetChecks() []string
	GetLoggingConfig() LoggingConfig
	GetDBConfig() DBConfig
	GetSyncConfig() SyncConfig
	GetExtractorConfig() ExtractorConfig
	GetSchedulerConfig() SchedulerConfig
	GetDeschedulerConfig() DeschedulerConfig
	GetKPIsConfig() KPIsConfig
	GetMonitoringConfig() MonitoringConfig
	GetMQTTConfig() MQTTConfig
	GetAPIConfig() APIConfig
	GetKeystoneConfig() KeystoneConfig
	// Check if the configuration is valid.
	Validate() error
}

Configuration for the cortex service.

type DBConfig

type DBConfig struct {
	Host      string            `json:"host"`
	Port      int               `json:"port"`
	Database  string            `json:"database"`
	User      string            `json:"user"`
	Password  string            `json:"password"`
	Reconnect DBReconnectConfig `json:"reconnect"`
}

Database configuration.

type DBReconnectConfig

type DBReconnectConfig struct {
	// The interval between liveness pings to the database.
	LivenessPingIntervalSeconds int `json:"livenessPingIntervalSeconds"`
	// The interval between reconnection attempts on connection loss.
	RetryIntervalSeconds int `json:"retryIntervalSeconds"`
	// The maximum number of reconnection attempts on connection loss before panic.
	MaxRetries int `json:"maxRetries"`
}

type DependencyConfig

type DependencyConfig struct {
	Sync struct {
		OpenStack struct {
			Nova struct {
				ObjectTypes []string `json:"types,omitempty"`
			} `json:"nova,omitempty"`
			Placement struct {
				ObjectTypes []string `json:"types,omitempty"`
			} `json:"placement,omitempty"`
		} `json:"openstack,omitempty"`
		Prometheus struct {
			Metrics []struct {
				Alias string `json:"alias,omitempty"`
				Type  string `json:"type,omitempty"`
			} `json:"metrics,omitempty"`
		} `json:"prometheus,omitempty"`
	}
	Extractors []string `json:"extractors,omitempty"`
}

Configuration that is passed in the config file to specify dependencies.

type DependencyGraph

type DependencyGraph[K comparable] struct {
	// Dependencies between the individual steps.
	Dependencies map[K][]K
	// List of individual steps.
	Nodes []K
}

Dependency graph.

func (*DependencyGraph[K]) DistinctSubgraphs

func (g *DependencyGraph[K]) DistinctSubgraphs(condition func(K) bool) []DependencyGraph[K]

Get distinct subgraphs from the dependency graph where a condition is met.

Example: consider the following graph:

  • A -> B (condition: true) -> C, D (condition: true) -> E
  • F (condition: true) -> G, H -> I

The result would be two subgraphs: B -> C, D -> E and F -> G, H -> I. The subgraph after node D is part of B's subgraph, therefore we don't get three results.

func (*DependencyGraph[K]) Resolve

func (g *DependencyGraph[K]) Resolve() ([][]K, error)

Resolve the dependency graph into an execution order. This function returns a list of steps which may contain one or multiple steps that can be run in parallel. It starts with the steps that have no dependencies and then recursively resolves the dependencies of the steps that depend on them.

type DeschedulerConfig

type DeschedulerConfig struct {
	Nova NovaDeschedulerConfig `json:"nova"`
}

Configuration for the descheduler module.

type DeschedulerStepConfig

type DeschedulerStepConfig struct {
	// The name of the step.
	Name string `json:"name"`
	// Custom options for the step, as a raw yaml map.
	Options RawOpts `json:"options,omitempty"`
	// The dependencies this step needs.
	DependencyConfig `json:"dependencies,omitempty"`
}

type ExtractorConfig

type ExtractorConfig struct {
	Plugins []FeatureExtractorConfig `json:"plugins"`
}

Configuration for the features module.

type FeatureExtractorConfig

type FeatureExtractorConfig struct {
	// The name of the extractor.
	Name string `json:"name"`
	// Custom options for the extractor, as a raw yaml map.
	Options RawOpts `json:"options,omitempty"`
	// The dependencies this extractor needs.
	DependencyConfig `json:"dependencies,omitempty"`
	// Recency that tells how old a feature needs to be to be recalculated
	RecencySeconds *int `json:"recencySeconds,omitempty"`
	// MQTT topic to publish the features to.
	// If not set, the extractor will not publish features to MQTT.
	MQTTTopic string `json:"mqttTopic,omitempty"`
}

type JsonOpts

type JsonOpts[Options any] struct {
	// Options loaded from a json config using the Load method.
	Options Options
}

Mixin that adds the ability to load options from a json map. Usage: type StructUsingOpts struct { conf.JsonOpts[MyOpts] }

func (*JsonOpts[Options]) Load

func (s *JsonOpts[Options]) Load(opts RawOpts) error

Set the options contained in the opts json map.

type KPIPluginConfig

type KPIPluginConfig struct {
	// The name of the KPI plugin.
	Name string `json:"name"`
	// Custom options for the KPI plugin, as a raw json map.
	Options RawOpts `json:"options,omitempty"`
	// The dependencies this KPI plugin needs.
	DependencyConfig `json:"dependencies,omitempty"`
}

Configuration for a single KPI plugin.

type KPIsConfig

type KPIsConfig struct {
	// KPI plugins to use.
	Plugins []KPIPluginConfig `json:"plugins"`
}

Configuration for the kpis module.

type KeystoneConfig

type KeystoneConfig struct {
	// The URL of the keystone service.
	URL string `json:"url"`
	// The SSO certificate to use. If none is given, we won't
	// use SSO to connect to the openstack services.
	SSO SSOConfig `json:"sso,omitempty"`
	// The OpenStack username (OS_USERNAME in openstack cli).
	OSUsername string `json:"username"`
	// The OpenStack password (OS_PASSWORD in openstack cli).
	OSPassword string `json:"password"`
	// The OpenStack project name (OS_PROJECT_NAME in openstack cli).
	OSProjectName string `json:"projectName"`
	// The OpenStack user domain name (OS_USER_DOMAIN_NAME in openstack cli).
	OSUserDomainName string `json:"userDomainName"`
	// The OpenStack project domain name (OS_PROJECT_DOMAIN_NAME in openstack cli).
	OSProjectDomainName string `json:"projectDomainName"`
}

Configuration for the keystone authentication.

type LoggingConfig

type LoggingConfig struct {
	// The log level to use (debug, info, warn, error).
	LevelStr string `json:"level"`
	// The log format to use (json, text).
	Format string `json:"format"`
}

Configuration for structured logging.

func (LoggingConfig) Level

func (c LoggingConfig) Level() slog.Level

Conform to the slog.Leveler interface.

func (LoggingConfig) SetDefaultLogger

func (c LoggingConfig) SetDefaultLogger()

Set the structured logger as given in the config.

type MQTTConfig

type MQTTConfig struct {
	// The URL of the MQTT broker to use for mqtt.
	URL string `json:"url"`
	// Credentials for the MQTT broker.
	Username  string              `json:"username"`
	Password  string              `json:"password"`
	Reconnect MQTTReconnectConfig `json:"reconnect"`
}

Configuration for the mqtt client.

type MQTTReconnectConfig

type MQTTReconnectConfig struct {
	// The interval between reconnection attempts on connection loss.
	RetryIntervalSeconds int `json:"retryIntervalSeconds"`

	// The maximum number of reconnection attempts on connection loss before panic.
	MaxRetries int `json:"maxRetries"`
}

type ManilaSchedulerConfig

type ManilaSchedulerConfig struct {
	// Pipelines in this scheduler.
	Pipelines []ManilaSchedulerPipelineConfig `json:"pipelines"`
}

type ManilaSchedulerPipelineConfig

type ManilaSchedulerPipelineConfig struct {
	// Scheduler step plugins by their name.
	Plugins []SchedulerStepConfig `json:"plugins"`

	// The name of this scheduler pipeline.
	// The name is used to distinguish and route between multiple pipelines.
	Name string `json:"name"`
}

type MonitoringConfig

type MonitoringConfig struct {
	// The labels to add to all metrics.
	Labels map[string]string `json:"labels"`

	// The port to expose the metrics on.
	Port int `json:"port"`
}

Configuration for the monitoring module.

type NovaDeschedulerConfig

type NovaDeschedulerConfig struct {
	// The availability of the nova service, such as "public", "internal", or "admin".
	Availability string `json:"availability"`
	// The steps to execute in the descheduler.
	Plugins []DeschedulerStepConfig `json:"plugins"`
	// If dry-run is disabled (by default its enabled).
	DisableDryRun bool `json:"disableDryRun,omitempty"`
}

Configuration for the nova descheduler.

type NovaHypervisorType

type NovaHypervisorType = string
const (
	NovaHypervisorTypeQEMU   NovaHypervisorType = "QEMU"
	NovaHypervisorTypeCH     NovaHypervisorType = "CH" // Cloud hypervisor
	NovaHypervisorTypeVMware NovaHypervisorType = "VMware vCenter Server"
	NovaHypervisorTypeIronic NovaHypervisorType = "ironic"
)

type NovaSchedulerConfig

type NovaSchedulerConfig struct {
	// Pipelines in this scheduler.
	Pipelines []NovaSchedulerPipelineConfig `json:"pipelines"`
	// Configuration for the Liquid API.
	LiquidAPI NovaSchedulerLiquidAPIConfig `json:"liquidAPI"`
}

type NovaSchedulerLiquidAPIConfig

type NovaSchedulerLiquidAPIConfig struct {
	// Hypervisors that should be handled by the api.
	Hypervisors []NovaHypervisorType `json:"hypervisors"`
}

type NovaSchedulerPipelineConfig

type NovaSchedulerPipelineConfig struct {
	// Scheduler step plugins by their name.
	Plugins []SchedulerStepConfig `json:"plugins"`

	// Dependencies needed by all the Nova scheduler steps.
	DependencyConfig `json:"dependencies,omitempty"`

	// The name of this scheduler pipeline.
	// The name is used to distinguish and route between multiple pipelines.
	Name string `json:"name"`

	// If all available hosts should be selected in the request,
	// regardless of what nova sends us in the request.
	// By default, this is false (use the hosts nova gives us).
	PreselectAllHosts bool `json:"preselectAllHosts"`
}

type NovaSchedulerStepHostCapabilities

type NovaSchedulerStepHostCapabilities struct {
	// If given, the scheduler step will only be applied to hosts
	// that have ONE of the given traits.
	AnyOfTraitInfixes []string `json:"anyOfTraitInfixes,omitempty"`
	// If given, the scheduler step will only be applied to hosts
	// that have ONE of the given hypervisor types.
	AnyOfHypervisorTypeInfixes []string `json:"anyOfHypervisorTypeInfixes,omitempty"`
	// If given, the scheduler step will only be applied to hosts
	// that have ALL of the given traits.
	AllOfTraitInfixes []string `json:"allOfTraitInfixes,omitempty"`

	// If the selection should be inverted, i.e. the step should be applied to hosts
	// that do NOT match the aforementioned criteria.
	InvertSelection bool `json:"invertSelection,omitempty"`
}

func (NovaSchedulerStepHostCapabilities) IsUndefined

func (s NovaSchedulerStepHostCapabilities) IsUndefined() bool

type NovaSchedulerStepHostSelector

type NovaSchedulerStepHostSelector struct {
	// One of: "trait", "hypervisorType"
	Subject string `json:"subject"`
	// Selector type, currently only "infix" is supported.
	Type string `json:"type,omitempty"`
	// Value of the selector (typed to the given type).
	Value any `json:"value,omitempty"`
	// How the selector should be applied:
	// Let A be the previous set of hosts, and B the scoped hosts.
	// - "union" means that the scoped hosts are added to the previous set of hosts.
	// - "difference" means that the scoped hosts are removed from the previous set of hosts.
	// - "intersection" means that the scoped hosts are the only ones that remain in the previous set of hosts.
	Operation string `json:"operation,omitempty"`
}

type NovaSchedulerStepScope

type NovaSchedulerStepScope struct {
	// Selectors applied to the compute hosts.
	HostSelectors []NovaSchedulerStepHostSelector `json:"hostSelectors,omitempty"`
	// Selectors applied to the given nova spec.
	SpecSelectors []NovaSchedulerStepSpecSelector `json:"specSelectors,omitempty"`
}

Scope that defines which hosts a scheduler step should be applied to. In addition, it also defines the traits for which the step should be applied.

type NovaSchedulerStepSpecScope

type NovaSchedulerStepSpecScope struct {
	// If given, the scheduler step will only be applied to specs
	// that contain ALL of the following infixes.
	AllOfFlavorNameInfixes []string `json:"allOfFlavorNameInfixes,omitempty"`
}

func (NovaSchedulerStepSpecScope) IsUndefined

func (s NovaSchedulerStepSpecScope) IsUndefined() bool

type NovaSchedulerStepSpecSelector

type NovaSchedulerStepSpecSelector struct {
	// One of: "flavor", "vmware"
	Subject string `json:"subject"`
	// Selector type: bool, infix.
	Type string `json:"type,omitempty"`
	// Value of the selector (typed to the given type).
	Value any `json:"value,omitempty"`
	// What to do if the selector is matched:
	// - "skip" means that the step is skipped.
	// - "continue" means that the step is applied.
	Action string `json:"action,omitempty"`
}

type RawOpts

type RawOpts struct {
	// contains filtered or unexported fields
}

Raw options that are not directly unmarshalled when loading from json. Usage: call Unmarshal to unmarshal the options into a struct.

func NewRawOpts

func NewRawOpts(rawJson string) RawOpts

Create a new RawOpts instance with the given json string.

func (*RawOpts) Unmarshal

func (msg *RawOpts) Unmarshal(v any) error

Call the postponed unmarshal function and unmarshal the options into a struct.

func (*RawOpts) UnmarshalJSON

func (msg *RawOpts) UnmarshalJSON(data []byte) error

Override the default json unmarshal behavior to postpone the unmarshal.

type SSOConfig

type SSOConfig struct {
	Cert    string `json:"cert,omitempty"`
	CertKey string `json:"certKey,omitempty"`

	// If the certificate is self-signed, we need to skip verification.
	SelfSigned bool `json:"selfSigned,omitempty"`
}

Configuration for single-sign-on (SSO).

type SchedulerAPIConfig

type SchedulerAPIConfig struct {
	// If request bodies should be logged out.
	// This feature is intended for debugging purposes only.
	LogRequestBodies bool `json:"logRequestBodies"`
}

Configuration for the scheduler API.

type SchedulerConfig

type SchedulerConfig struct {
	Nova   NovaSchedulerConfig   `json:"nova"`
	Manila ManilaSchedulerConfig `json:"manila"`
	Cinder CinderSchedulerConfig `json:"cinder"`

	API SchedulerAPIConfig `json:"api"`
}

Configuration for the scheduler module.

type SchedulerStepConfig

type SchedulerStepConfig struct {
	// The name of the step implementation.
	Name string `json:"name"`
	// The alias of this step, if any.
	//
	// The alias can be used to distinguish between different configurations
	// of the same step, or use a more specific name.
	Alias string `json:"alias,omitempty"`
	// Custom options for the step, as a raw yaml map.
	Options RawOpts `json:"options,omitempty"`
	// The dependencies this step needs.
	DependencyConfig `json:"dependencies,omitempty"`
	// The validations to use for this step.
	DisabledValidations SchedulerStepDisabledValidationsConfig `json:"disabledValidations,omitempty"`

	// The scope of the step, i.e. which hosts it should be applied to.
	Scope *NovaSchedulerStepScope `json:"scope,omitempty"`
}

type SchedulerStepDisabledValidationsConfig

type SchedulerStepDisabledValidationsConfig struct {
	// Whether to validate that no subjects are removed or added from the scheduler
	// step. This should only be disabled for scheduler steps that remove subjects.
	// Thus, if no value is provided, the default is false.
	SameSubjectNumberInOut bool `json:"sameSubjectNumberInOut,omitempty"`
	// Whether to validate that, after running the step, there are remaining subjects.
	// This should only be disabled for scheduler steps that are expected to
	// remove all subjects.
	SomeSubjectsRemain bool `json:"someSubjectsRemain,omitempty"`
}

Config for which validations to disable for a scheduler step.

type SharedConfig

type SharedConfig struct {
	// The checks to run, in this particular order.
	Checks []string `json:"checks"`

	LoggingConfig     `json:"logging"`
	DBConfig          `json:"db"`
	SyncConfig        `json:"sync"`
	ExtractorConfig   `json:"extractor"`
	SchedulerConfig   `json:"scheduler"`
	DeschedulerConfig `json:"descheduler"`
	MonitoringConfig  `json:"monitoring"`
	KPIsConfig        `json:"kpis"`
	MQTTConfig        `json:"mqtt"`
	APIConfig         `json:"api"`
	KeystoneConfig    `json:"keystone"`
}

func (*SharedConfig) GetAPIConfig

func (c *SharedConfig) GetAPIConfig() APIConfig

func (*SharedConfig) GetChecks

func (c *SharedConfig) GetChecks() []string

func (*SharedConfig) GetDBConfig

func (c *SharedConfig) GetDBConfig() DBConfig

func (*SharedConfig) GetDeschedulerConfig

func (c *SharedConfig) GetDeschedulerConfig() DeschedulerConfig

func (*SharedConfig) GetExtractorConfig

func (c *SharedConfig) GetExtractorConfig() ExtractorConfig

func (*SharedConfig) GetKPIsConfig

func (c *SharedConfig) GetKPIsConfig() KPIsConfig

func (*SharedConfig) GetKeystoneConfig

func (c *SharedConfig) GetKeystoneConfig() KeystoneConfig

func (*SharedConfig) GetLoggingConfig

func (c *SharedConfig) GetLoggingConfig() LoggingConfig

func (*SharedConfig) GetMQTTConfig

func (c *SharedConfig) GetMQTTConfig() MQTTConfig

func (*SharedConfig) GetMonitoringConfig

func (c *SharedConfig) GetMonitoringConfig() MonitoringConfig

func (*SharedConfig) GetSchedulerConfig

func (c *SharedConfig) GetSchedulerConfig() SchedulerConfig

func (*SharedConfig) GetSyncConfig

func (c *SharedConfig) GetSyncConfig() SyncConfig

func (*SharedConfig) Validate

func (c *SharedConfig) Validate() error

Check if all dependencies are satisfied.

type SyncConfig

type SyncConfig struct {
	Prometheus SyncPrometheusConfig `json:"prometheus"`
	OpenStack  SyncOpenStackConfig  `json:"openstack"`
}

Configuration for the sync module.

type SyncOpenStackCinderConfig

type SyncOpenStackCinderConfig struct {
	// Availability of the service, such as "public", "internal", or "admin".
	Availability string `json:"availability"`
	// The types of resources to sync.
	Types []string `json:"types"`
}

Configuration for the cinder service

type SyncOpenStackConfig

type SyncOpenStackConfig struct {
	// Configuration for the nova service.
	Nova SyncOpenStackNovaConfig `json:"nova"`
	// Configuration for the placement service.
	Placement SyncOpenStackPlacementConfig `json:"placement"`
	// Configuration for the manila service.
	Manila SyncOpenStackManilaConfig `json:"manila"`
	// Configuration for the identity service.
	Identity SyncOpenStackIdentityConfig `json:"identity"`
	// Configuration for the limes service.
	Limes SyncOpenStackLimesConfig `json:"limes"`
	// Configuration for the cinder service.
	Cinder SyncOpenStackCinderConfig `json:"cinder"`
}

Configuration for the sync/openstack module.

type SyncOpenStackIdentityConfig

type SyncOpenStackIdentityConfig struct {
	// Availability of the service, such as "public", "internal", or "admin".
	Availability string `json:"availability"`
	// The types of resources to sync.
	Types []string `json:"types"`
}

Configuration for the identity service.

type SyncOpenStackLimesConfig

type SyncOpenStackLimesConfig struct {
	// Availability of the service, such as "public", "internal", or "admin".
	Availability string `json:"availability"`
	// The types of resources to sync.
	Types []string `json:"types"`
}

Configuration for the limes service.

type SyncOpenStackManilaConfig

type SyncOpenStackManilaConfig struct {
	// Availability of the service, such as "public", "internal", or "admin".
	Availability string `json:"availability"`
	// The types of resources to sync.
	Types []string `json:"types"`
}

Configuration for the manila service.

type SyncOpenStackNovaConfig

type SyncOpenStackNovaConfig struct {
	// Availability of the service, such as "public", "internal", or "admin".
	Availability string `json:"availability"`
	// The types of resources to sync.
	Types []string `json:"types"`
	// Time frame in minutes for the changes-since parameter when fetching deleted servers.
	DeletedServersChangesSinceMinutes *int `json:"deletedServersChangesSinceMinutes,omitempty"`
}

Configuration for the nova service.

type SyncOpenStackPlacementConfig

type SyncOpenStackPlacementConfig struct {
	// Availability of the service, such as "public", "internal", or "admin".
	Availability string `json:"availability"`
	// The types of resources to sync.
	Types []string `json:"types"`
}

Configuration for the placement service.

type SyncPrometheusConfig

type SyncPrometheusConfig struct {
	Hosts   []SyncPrometheusHostConfig   `json:"hosts,omitempty"`
	Metrics []SyncPrometheusMetricConfig `json:"metrics,omitempty"`
}

Configuration for the sync/prometheus module containing a list of metrics.

type SyncPrometheusHostConfig

type SyncPrometheusHostConfig struct {
	// The name of the prometheus host.
	Name string `json:"name"`
	// The URL of the prometheus host.
	URL string `json:"url"`
	// The SSO configuration for this host.
	SSO SSOConfig `json:"sso,omitempty"`
	// The types of metrics this host provides.
	ProvidedMetricTypes []string `json:"provides"`
}

Configuration for a single prometheus host.

type SyncPrometheusMetricConfig

type SyncPrometheusMetricConfig struct {
	// The query to use to fetch the metric.
	Query string `json:"query"`
	// Especially when a more complex query is used, we need an alias
	// under which the table will be stored in the database.
	// Additionally, this alias is used to reference the metric in the
	// feature extractors as dependency.
	Alias string `json:"alias"`
	// The type of the metric, mapping directly to a metric model.
	Type string `json:"type"`

	TimeRangeSeconds  *int `json:"timeRangeSeconds,omitempty"`
	IntervalSeconds   *int `json:"intervalSeconds,omitempty"`
	ResolutionSeconds *int `json:"resolutionSeconds,omitempty"`
}

Metric configuration for the sync/prometheus module.

Jump to

Keyboard shortcuts

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