analyze

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultAlwaysGreenAnalyzer is an analyzer that always returns OK status.
	// It's empty right now, but it can be configured to match specific kinds
	// we want to always consider OK.
	DefaultAlwaysGreenAnalyzer = AlwaysGreenAnalyzer{
		Kinds: []schema.GroupKind{
			{Group: "", Kind: "Namespace"},
		},
	}

	// ConditionStatusNoMatch is returned by condition analyzer when it's not
	// applicable to the condition.
	ConditionStatusNoMatch = status.ConditionStatus{}

	// Register is a global registry of analyzers.
	Register = &AnalyzerRegister{}
)
View Source
var (

	// CommonConditionsAnalyzer is a generic condition analyzer that can be used
	// for any condition type. It's one of the default analyzers.
	CommonConditionsAnalyzer = GenericConditionAnalyzer{
		MatchAll:   true,
		Conditions: NewStringMatchers("Ready"),
		ReversedPolarityConditions: append(NewRegexpMatchers("Degraded", "Pressure", "Detected"),
			NewStringMatchers("Progressing")...),
		ProgressingConditions: NewStringMatchers("Progressing"),
		WarningConditions:     NewRegexpMatchers("Degraded", "Pressure", "Detected"),
		UnknownConditions:     NewRegexpMatchers("Disabled"),
	}

	// DefaultConditionAnalyzers is a list of condition analyzers that are used
	// by default. They should be applicable to a broad range of resources.
	DefaultConditionAnalyzers = []ConditionAnalyzer{CommonConditionsAnalyzer}
)

ignoredGroupKinds is a list of GroupKinds that are ignored by the default when evaluating sub-objects. These are mostly resources that are not interesting for the status evaluation.

Functions

func AggregateResult

func AggregateResult(obj *status.Object, subStatuses []status.ObjectStatus,
	conditions []status.ConditionStatus) status.ObjectStatus

func AnalyzeConditions

func AnalyzeConditions(conditions []*metav1.Condition, analyzers []ConditionAnalyzer) []status.ConditionStatus

func AnalyzeObjectConditions

func AnalyzeObjectConditions(obj *status.Object, analyzers []ConditionAnalyzer) ([]status.ConditionStatus, error)

AnalyzeObjectConditions analyzes the conditions of the object using the provided analyzers. It expects the conditions to be in the "status.conditions" field of the object.

func AnalyzeObservedGeneration

func AnalyzeObservedGeneration(obj *status.Object) []status.ConditionStatus

GenericConditionAnalyzers adds additional conditions based on values of generation and observedGeneration fields.

func AnalyzeRawConditions

func AnalyzeRawConditions(data []interface{}, analyzers []ConditionAnalyzer) ([]status.ConditionStatus, error)

func ConditionStatusError

func ConditionStatusError(cond *metav1.Condition) status.ConditionStatus

func ConditionStatusOk

func ConditionStatusOk(cond *metav1.Condition) status.ConditionStatus

func ConditionStatusProgressing

func ConditionStatusProgressing(cond *metav1.Condition) status.ConditionStatus

func ConditionStatusUnknown

func ConditionStatusUnknown(cond *metav1.Condition) status.ConditionStatus

func ConditionStatusUnknownWithError

func ConditionStatusUnknownWithError(cond *metav1.Condition, err error) status.ConditionStatus

func ConditionStatusWarning

func ConditionStatusWarning(cond *metav1.Condition) status.ConditionStatus

func DefaultAnalyzerInit

func DefaultAnalyzerInit(e *eval.Evaluator) eval.Analyzer

func DefaultAnalyzers

func DefaultAnalyzers() []eval.AnalyzerInit

func FromUnstructured

func FromUnstructured(data map[string]interface{}, obj interface{}) error

func GenericOwnerQuerySpec

func GenericOwnerQuerySpec(obj *status.Object) eval.OwnerQuerySpec

func SyntheticCondition

func SyntheticCondition(condType string, statusVal bool, reason, message string,
	lastTransitionTime time.Time) *metav1.Condition

SyntheticCondition creates a synthetic condition with the given values. It's used for cases when the condition is not present in the object but we want to indicate a particular status. For example, when the object is not reporting Ready condition, we can synthesize it based on other conditions.

func SyntheticConditionError

func SyntheticConditionError(condType, reason, message string) status.ConditionStatus

func SyntheticConditionOk

func SyntheticConditionOk(condType, message string) status.ConditionStatus

func SyntheticConditionProgressing

func SyntheticConditionProgressing(condType, reason, message string) status.ConditionStatus

func SyntheticConditionWarning

func SyntheticConditionWarning(condType, reason, message string) status.ConditionStatus

Types

type AlwaysGreenAnalyzer

type AlwaysGreenAnalyzer struct {
	Kinds []schema.GroupKind
}

AlwaysGreenAnalyzer is an analyzer that always returns OK status for the supported kinds.

func (AlwaysGreenAnalyzer) Analyze

func (AlwaysGreenAnalyzer) Supports

func (a AlwaysGreenAnalyzer) Supports(obj *status.Object) bool

type AnalyzerRegister

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

AnalyzerRegister is a registry of analyzers. It allows to register new analyzers and ignored GroupKinds.

func (*AnalyzerRegister) AnalyzerInits

func (r *AnalyzerRegister) AnalyzerInits() []eval.AnalyzerInit

func (*AnalyzerRegister) Register

func (r *AnalyzerRegister) Register(a ...eval.AnalyzerInit)

Register registers new analyzers.

func (*AnalyzerRegister) RegisterIgnoredKinds

func (r *AnalyzerRegister) RegisterIgnoredKinds(gk ...schema.GroupKind)

func (*AnalyzerRegister) RegisterSimple

func (r *AnalyzerRegister) RegisterSimple(as ...eval.Analyzer)

RegisterSimple registers analyzers without any additional configuration.

type ConditionAnalyzer

type ConditionAnalyzer interface {
	Analyze(*metav1.Condition) status.ConditionStatus
}

type DeploymentAnalyzer

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

func (DeploymentAnalyzer) Analyze

func (DeploymentAnalyzer) Supports

func (_ DeploymentAnalyzer) Supports(obj *status.Object) bool

type GenericAnalyzer

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

GenericAnalyzer is an analyzer is a generic implementation of an analyzer. It evaluates object conditions against conditionsAnalyzers. It also evaluates the sub-objects based on owner references.

func (*GenericAnalyzer) Analyze

func (a *GenericAnalyzer) Analyze(obj *status.Object) status.ObjectStatus

func (*GenericAnalyzer) Supports

func (a *GenericAnalyzer) Supports(obj *status.Object) bool

type GenericConditionAnalyzer

type GenericConditionAnalyzer struct {
	MatchAll                   bool
	Conditions                 []Matcher
	ReversedPolarityConditions []Matcher
	WarningConditions          []Matcher
	ProgressingConditions      []Matcher
	UnknownConditions          []Matcher
}

GenericConditionAnalyzer is a generic condition analyzer that can be used for any condition type. It can be configured to match all conditions or only specific ones. The analyzer can also be configured to reverse the polarity of the condition: by default, True is considered OK and False is considered Error. The ReversedPolarityTypes is used for conditions that should be treated the other way around: False is OK, True is Error, e.g. Degraded.

By default, when a condition is matched and the value is in unexpected state, it's considered as Error, unless the condition is matched by `WarningConditions`, `UnknownConditions` or `ProgressingConditions`, in which case the corresponding status is set.

func (GenericConditionAnalyzer) Analyze

type Matcher added in v0.2.0

type Matcher interface {
	Match(string) bool
}

func NewRegexpMatchers added in v0.2.0

func NewRegexpMatchers(patterns ...string) []Matcher

func NewStringMatchers added in v0.2.0

func NewStringMatchers(patterns ...string) []Matcher

type PVCAnalyzer added in v0.2.0

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

func (PVCAnalyzer) Analyze added in v0.2.0

func (a PVCAnalyzer) Analyze(obj *status.Object) status.ObjectStatus

func (PVCAnalyzer) Supports added in v0.2.0

func (_ PVCAnalyzer) Supports(obj *status.Object) bool

type PodAnalyzer

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

func (PodAnalyzer) Analyze

func (a PodAnalyzer) Analyze(obj *status.Object) status.ObjectStatus

func (PodAnalyzer) Supports

func (_ PodAnalyzer) Supports(obj *status.Object) bool

type RegexpMatcher added in v0.2.0

type RegexpMatcher regexp.Regexp

func (*RegexpMatcher) Match added in v0.2.0

func (m *RegexpMatcher) Match(s string) bool

type ReplicaSetAnalyzer

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

func (ReplicaSetAnalyzer) Analyze

func (ReplicaSetAnalyzer) Supports

func (_ ReplicaSetAnalyzer) Supports(obj *status.Object) bool

type ServiceAnalyzer

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

func (ServiceAnalyzer) Analyze

func (ServiceAnalyzer) Supports

func (_ ServiceAnalyzer) Supports(obj *status.Object) bool

type StringMatcher added in v0.2.0

type StringMatcher string

func (StringMatcher) Match added in v0.2.0

func (m StringMatcher) Match(s string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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