dispatcher

package
v0.0.0-...-8d994d8 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetermineCloud

func DetermineCloud(jobBase prowconfig.JobBase) string

DetermineCloud determines which cloud this job should run. It returns the value of ci-operator.openshift.io/cloud if it is none empty. The label is set by prow-gen for multistage tests. For template tests and hand-crafted tests, it returns the value of env. var. CLUSTER_TYPE from the job's spec.

func GetJobVolumesFromPrometheus

func GetJobVolumesFromPrometheus(ctx context.Context, prometheusAPI PrometheusAPI, ts time.Time) (map[string]float64, error)

GetJobVolumesFromPrometheus gets job volumes from a Prometheus server for the given time

func SaveConfig

func SaveConfig(config *Config, configPath string) error

SaveConfig saves config to a file

Types

type BuildFarmConfig

type BuildFarmConfig struct {
	FilenamesRaw []string         `json:"filenames,omitempty"`
	Filenames    sets.Set[string] `json:"-"`
}

type Config

type Config struct {
	// the job will be run on the same cloud as the one for the e2e test
	DetermineE2EByJob bool `json:"determineE2EByJob,omitempty"`
	// the job will be run on the target cloud if it otherwise runs on the source cloud.
	// The field has effect only when DetermineE2EByJob is true.
	CloudMapping map[api.Cloud]api.Cloud `json:"cloudMapping,omitempty"`
	// the cluster cluster name if no other condition matches
	Default api.Cluster `json:"default"`
	// the cluster name for ssh bastion jobs
	SSHBastion api.Cluster `json:"sshBastion"`
	// the cluster names for kvm jobs
	KVM []api.Cluster `json:"kvm"`
	// the cluster names for no-builds jobs
	NoBuilds []api.Cluster `json:"noBuilds,omitempty"`
	// Groups maps a group of jobs to a cluster
	Groups JobGroups `json:"groups"`
	// BuildFarm maps groups of jobs to a cloud provider, like GCP
	BuildFarm map[api.Cloud]map[api.Cluster]*BuildFarmConfig `json:"buildFarm,omitempty"`
	// BuildFarmCloud maps sets of clusters to a cloud provider, like GCP
	BuildFarmCloud map[api.Cloud][]string `json:"-"`
}

Config is the configuration file of this tools, which defines the cluster parameter for each Prow job, i.e., where it runs

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

LoadConfig loads config from a file

func (*Config) DetermineCloudMapping

func (config *Config) DetermineCloudMapping(jobBase prowconfig.JobBase) string

DetermineCloudMapping determines if for a given cloud there is a replacement to map, eg for cost saving reasons

func (*Config) DetermineClusterForJob

func (config *Config) DetermineClusterForJob(jobBase prowconfig.JobBase, path string) (clusterName api.Cluster, mayBeRelocated bool, _ error)

DetermineClusterForJob return the cluster for a prow job and if it can be relocated to a cluster in build farm

func (*Config) GetClusterForJob

func (config *Config) GetClusterForJob(jobBase prowconfig.JobBase, path string) (api.Cluster, error)

GetClusterForJob returns a cluster for a prow job

func (*Config) IsInBuildFarm

func (config *Config) IsInBuildFarm(clusterName api.Cluster) api.Cloud

IsInBuildFarm returns the cloudProvider if the cluster is in the build farm; empty string otherwise.

func (*Config) MatchingPathRegEx

func (config *Config) MatchingPathRegEx(path string) bool

MatchingPathRegEx returns true if the given path matches a path regular expression defined in a config's group

func (*Config) Validate

func (config *Config) Validate() error

Validate checks if the config is valid

type Group

type Group struct {
	// a list of job names
	Jobs []string `json:"jobs,omitempty"`
	// a list of regexes of the file paths
	Paths []string `json:"paths,omitempty"`

	PathREs []*regexp.Regexp `json:"-"`
}

Group is a group of jobs

type JobGroups

type JobGroups = map[api.Cluster]Group

JobGroups maps a group of jobs to a cluster

type PrometheusAPI

type PrometheusAPI interface {
	// Query performs a query for the given time.
	Query(ctx context.Context, query string, ts time.Time, opts ...prometheusapi.Option) (model.Value, prometheusapi.Warnings, error)
}

PrometheusAPI defines what we expect Prometheus to do in the package

type PrometheusOptions

type PrometheusOptions struct {
	PrometheusURL             string
	PrometheusUsername        string
	PrometheusPasswordPath    string
	PrometheusBearerTokenPath string
}

PrometheusOptions exposes options used in contacting a Prometheus instance

func (*PrometheusOptions) AddFlags

func (o *PrometheusOptions) AddFlags(fs *flag.FlagSet)

AddFlags sets up the flags for PrometheusOptions

func (*PrometheusOptions) NewPrometheusClient

func (o *PrometheusOptions) NewPrometheusClient(secretGetter func(string) []byte) (api.Client, error)

NewPrometheusClient return a Prometheus client

func (*PrometheusOptions) Validate

func (o *PrometheusOptions) Validate() error

Validate validates the values in the options

Jump to

Keyboard shortcuts

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