pod_scaler

package
v0.0.0-...-3e092da Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ProwLabelNameCreated model.LabelName = "label_created_by_prow"
	ProwLabelNameContext model.LabelName = "label_prow_k8s_io_context"
	ProwLabelNameJob     model.LabelName = "label_prow_k8s_io_job"
	ProwLabelNameType    model.LabelName = "label_prow_k8s_io_type"
	ProwLabelNameOrg     model.LabelName = "label_prow_k8s_io_refs_org"
	ProwLabelNameRepo    model.LabelName = "label_prow_k8s_io_refs_repo"
	ProwLabelNameBranch  model.LabelName = "label_prow_k8s_io_refs_base_ref"

	LabelNameRehearsal model.LabelName = "label_ci_openshift_org_rehearse"
	LabelNameCreated   model.LabelName = "label_created_by_ci"
	LabelNameOrg       model.LabelName = "label_ci_openshift_io_metadata_org"
	LabelNameRepo      model.LabelName = "label_ci_openshift_io_metadata_repo"
	LabelNameBranch    model.LabelName = "label_ci_openshift_io_metadata_branch"
	LabelNameVariant   model.LabelName = "label_ci_openshift_io_metadata_variant"
	LabelNameTarget    model.LabelName = "label_ci_openshift_io_metadata_target"
	LabelNameStep      model.LabelName = "label_ci_openshift_io_metadata_step"
	LabelNamePod       model.LabelName = "pod"
	LabelNameContainer model.LabelName = "container"
	LabelNameBuild     model.LabelName = "label_openshift_io_build_name"
	LabelNameRelease   model.LabelName = "label_ci_openshift_io_release"
	LabelNameApp       model.LabelName = "label_app"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedQuery

type CachedQuery struct {
	// Query is the query we executed against Prometheus to get this data.
	Query string `json:"query"`
	// RangesByCluster stores time ranges for which we've succeeded in getting this
	// data fromm Prometheus servers on the clusters we're querying.
	RangesByCluster map[string][]TimeRange `json:"ranges_by_cluster"`
	// Data holds the digested metric data, indexed by the metric fingerprint.
	// We digest data into log-linear histograms to allow for aggregation while
	// saving enormous amounts of space and incurring only minimal accuracy loss:
	// https://www.circonus.com/2018/11/the-problem-with-percentiles-aggregation-brings-aggravation/
	Data map[model.Fingerprint]*circonusllhist.HistogramWithoutLookups `json:"data"`
	// DataByMetaData indexes the metric data by the full set of labels.
	// The list of fingerprints is guaranteed to be unique for any set of labels
	// and will never contain more than fifty items.
	DataByMetaData map[FullMetadata][]model.Fingerprint `json:"data_by_meta_data"`
}

CachedQuery stores digested data for a query across clusters, as well as indices for the data to access it by the fully specific set of labels as well as a smaller set that uses the step for context only.

func (*CachedQuery) Prune

func (q *CachedQuery) Prune()

Prune ensures that no identifying set of labels contains more than fifty entries. We know that an entry fingerprint can only exist for one fully-qualified label set, but if the label set contains a multi-stage step, it will also be referenced in the additional per-step index.

func (*CachedQuery) Record

func (q *CachedQuery) Record(clusterName string, r TimeRange, matrix model.Matrix, logger *logrus.Entry)

Record adds the data in the matrix to the cache and records that the given cluster has successfully had this time range queried.

type FullMetadata

type FullMetadata struct {
	// Metadata identifies the ci-operator configuration for which this container ran.
	api.Metadata `json:"api_metadata"`
	// Target is the ci-operator --target for which this container ran.
	Target string `json:"target"`
	// Step is the multi-stage step for which this container ran, if any.
	Step string `json:"step,omitempty"`
	// Pod is the name of the pod which executed.
	Pod string `json:"pod"`
	// Container is the name of the container which executed.
	Container string `json:"container"`
}

FullMetadata identifies a container by all of the relevant labels, creating the most specific set of labels for any given container in our system. We can be certain that containers with the same labels at this level of specificity will execute with similar usage.

func MetadataFor

func MetadataFor(labels map[string]string, pod, container string) FullMetadata

func (FullMetadata) LogFields

func (m FullMetadata) LogFields() logrus.Fields

func (FullMetadata) MarshalText

func (m FullMetadata) MarshalText() (text []byte, err error)

MarshalText allows us to use this struct as a key in a JSON map when marshalling.

func (FullMetadata) StepMetadata

func (m FullMetadata) StepMetadata() StepMetadata

func (*FullMetadata) String

func (m *FullMetadata) String() string

func (*FullMetadata) UnmarshalText

func (m *FullMetadata) UnmarshalText(text []byte) error

UnmarshalText allows us to use this struct as a key in a JSON map when unmarshalling.

type StepMetadata

type StepMetadata struct {
	// Step is the multi-stage step for which this container ran, if any.
	Step string `json:"step,omitempty"`
	// Container is the name of the container which executed.
	Container string `json:"container"`
}

StepMetadata identifies a container running in the context of a step, where we expect that this container will execute in a similar way across all of the jobs for which it runs.

func (*StepMetadata) LogFields

func (m *StepMetadata) LogFields() logrus.Fields

func (StepMetadata) MarshalText

func (m StepMetadata) MarshalText() (text []byte, err error)

MarshalText allows us to use this struct as a key in a JSON map when marshalling.

func (*StepMetadata) String

func (m *StepMetadata) String() string

func (*StepMetadata) UnmarshalText

func (m *StepMetadata) UnmarshalText(text []byte) error

UnmarshalText allows us to use this struct as a key in a JSON map when unmarshalling.

type TimeRange

type TimeRange struct {
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
}

TimeRange describes a range of time, inclusive.

func UncoveredRanges

func UncoveredRanges(r TimeRange, coverage []TimeRange) []TimeRange

Jump to

Keyboard shortcuts

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