conditions

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// RetryNone means that this classification is not expected to ever retry (it's only ever set on for fatal errors)
	RetryNone = RetryClassification("None") // TODO: ??
	RetryFast = RetryClassification("RetryFast")
	RetrySlow = RetryClassification("RetrySlow")
)
View Source
const (
	// ConditionTypeReady is a condition indicating if the resource is ready or not.
	// A ready resource is one that has been successfully provisioned to Azure according to the
	// resource spec. It has reached the goal state. This usually means that the resource is ready
	// to use, but the exact meaning of Ready may vary slightly from resource to resource. Resources with
	// caveats to Ready's meaning will call that out in the resource specific documentation.
	ConditionTypeReady = "Ready"
)
View Source
const ReasonSucceeded = "Succeeded"

Variables

View Source
var (
	ReasonSecretNotFound    = Reason{Name: "SecretNotFound", RetryClassification: RetryFast}
	ReasonConfigMapNotFound = Reason{Name: "ConfigMapNotFound", RetryClassification: RetryFast}
	ReasonReferenceNotFound = Reason{Name: "ReferenceNotFound", RetryClassification: RetryFast}
	ReasonWaitingForOwner   = Reason{Name: "WaitingForOwner", RetryClassification: RetryFast}
)

Precondition reasons

View Source
var (
	ReasonAzureResourceNotFound               = Reason{Name: "AzureResourceNotFound", RetryClassification: RetrySlow}
	ReasonAdditionalKubernetesObjWriteFailure = Reason{Name: "FailedWritingAdditionalKubernetesObjects", RetryClassification: RetrySlow}
)

Post-ARM PUT reasons

View Source
var (
	ReasonReconciling                     = Reason{Name: "Reconciling", RetryClassification: RetryFast}
	ReasonDeleting                        = Reason{Name: "Deleting", RetryClassification: RetryFast}
	ReasonReconciliationFailedPermanently = Reason{Name: "ReconciliationFailedPermanently", RetryClassification: RetryNone}
	ReasonReconcileBlocked                = Reason{Name: "ReconciliationBlocked", RetryClassification: RetrySlow}
	ReasonReconcilePostponed              = Reason{Name: "ReconciliationPostponed", RetryClassification: RetrySlow}
	ReasonPostReconcileFailure            = Reason{Name: "PostReconciliationFailure", RetryClassification: RetrySlow}
)

Other reasons

View Source
var ReasonFailed = Reason{Name: "Failed", RetryClassification: RetrySlow}

ReasonFailed is a catch-all error code for when we don't have a more specific error classification

View Source
var ReasonSubscriptionMismatch = Reason{Name: "SubscriptionMismatch", RetryClassification: RetryFast}

Auth reasons

Functions

func SetCondition

func SetCondition(o Conditioner, new Condition)

SetCondition sets the provided Condition on the Conditioner. The condition is only set if the new condition is different from the existing condition of the same type. See Condition.IsEquivalent and Condition.ShouldOverwrite for more details.

func SetConditionReasonAware

func SetConditionReasonAware(o Conditioner, new Condition)

SetConditionReasonAware sets the provided Condition on the Conditioner. This is similar to SetCondition with one difference: SetConditionReasonAware understands common Reasons used by ASO and allows some of them to modify the standard Condition priority rules. This is primarily used to allow the Reconciling condition to overwrite Warning conditions raised by the operator that have been fixed. This is useful because sometimes getting a success or error from Azure can take a long time, and workflows like: submit -> warning -> fix warning -> call Azure -> wait -> success otherwise would continue reporting the Warning Condition until the final success step (possibly many minutes after the warning was resolved).

Types

type Condition

type Condition struct {
	// Type of condition.
	// +kubebuilder:validation:Required
	Type ConditionType `json:"type"`

	// Status of the condition, one of True, False, or Unknown.
	// +kubebuilder:validation:Required
	Status metav1.ConditionStatus `json:"status"`

	// Severity with which to treat failures of this type of condition.
	// For conditions which have positive polarity (Status == True is their normal/healthy state), this will be omitted when Status == True
	// For conditions which have negative polarity (Status == False is their normal/healthy state), this will be omitted when Status == False.
	// This is omitted in all cases when Status == Unknown
	// +kubebuilder:validation:Optional
	Severity ConditionSeverity `json:"severity,omitempty"`

	// LastTransitionTime is the last time the condition transitioned from one status to another.
	// +kubebuilder:validation:Required
	LastTransitionTime metav1.Time `json:"lastTransitionTime"`

	// ObservedGeneration is the .metadata.generation that the condition was set based upon. For instance, if
	// .metadata.generation is currently 12, but the .status.condition[x].observedGeneration is 9, the condition is out of date
	// with respect to the current state of the instance.
	// +kubebuilder:validation:Optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`

	// Reason for the condition's last transition.
	// Reasons are upper CamelCase (PascalCase) with no spaces. A reason is always provided, this field will not be empty.
	// +kubebuilder:validation:Required
	Reason string `json:"reason"`

	// Message is a human readable message indicating details about the transition. This field may be empty.
	// +kubebuilder:validation:Optional
	Message string `json:"message,omitempty"`
}

Condition defines an extension to status (an observation) of a resource +kubebuilder:object:generate=true

func GetCondition

func GetCondition(o Conditioner, conditionType ConditionType) (Condition, bool)

GetCondition gets the Condition with the specified type from the provided Conditioner. Returns the Condition and true if a Condition with the specified type is found, or an empty Condition and false if not.

func (Condition) Copy

func (c Condition) Copy() Condition

Copy returns an independent copy of the Condition

func (*Condition) DeepCopy

func (in *Condition) DeepCopy() *Condition

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition.

func (*Condition) DeepCopyInto

func (in *Condition) DeepCopyInto(out *Condition)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (Condition) IsEquivalent

func (c Condition) IsEquivalent(other Condition) bool

IsEquivalent returns true if this condition is equivalent to the passed in condition. Two conditions are equivalent if all of their fields EXCEPT LastTransitionTime are the same.

func (Condition) ShouldOverwrite

func (c Condition) ShouldOverwrite(other Condition) bool

ShouldOverwrite determines if this condition should overwrite the other condition.

func (Condition) String

func (c Condition) String() string

String returns a string representation of this condition

type ConditionSeverity

type ConditionSeverity string

ConditionSeverity expresses the severity of a Condition.

const (
	// ConditionSeverityError specifies that a failure of a condition type
	// should be viewed as an error. Errors are fatal to reconciliation and
	// mean that the user must take some action to resolve
	// the problem before reconciliation will be attempted again.
	ConditionSeverityError ConditionSeverity = "Error"

	// ConditionSeverityWarning specifies that a failure of a condition type
	// should be viewed as a warning. Warnings are informational. The operator
	// may be able to retry and resolve the warning without any action from the user, but
	// in some cases user action to resolve the warning will be required.
	ConditionSeverityWarning ConditionSeverity = "Warning"

	// ConditionSeverityInfo specifies that a failure of a condition type
	// should be viewed as purely informational. Things are working.
	// This is the happy path.
	ConditionSeverityInfo ConditionSeverity = "Info"

	// ConditionSeverityNone specifies that there is no condition severity.
	// For conditions which have positive polarity (Status == True is their normal/healthy state), this will set when Status == True
	// For conditions which have negative polarity (Status == False is their normal/healthy state), this will be set when Status == False.
	// Conditions in Status == Unknown always have a severity of None as well.
	// This is the default state for conditions.
	ConditionSeverityNone ConditionSeverity = ""
)

type ConditionType

type ConditionType string

type Conditioner

type Conditioner interface {
	GetConditions() Conditions
	SetConditions(conditions Conditions)
}

TODO: Hah, name...

type Conditions

type Conditions []Condition

func (Conditions) FindIndexByType

func (c Conditions) FindIndexByType(conditionType ConditionType) (int, bool)

FindIndexByType returns the index of the condition with the given ConditionType if it exists. If the Condition with the specified ConditionType is doesn't exist, the second boolean parameter is false.

type PositiveConditionBuilder

type PositiveConditionBuilder struct {
	Ready *ReadyConditionBuilder
	// contains filtered or unexported fields
}

PositiveConditionBuilder makes positive polarity conditions. A positive polarity condition is a condition where Status==True is the "happy path" state, and Status==False is a failure state.

func NewPositiveConditionBuilder

func NewPositiveConditionBuilder(clock clock.Clock) *PositiveConditionBuilder

NewPositiveConditionBuilder creates a new PositiveConditionBuilder for creating positive polarity conditions.

func (*PositiveConditionBuilder) MakeFalseCondition

func (b *PositiveConditionBuilder) MakeFalseCondition(conditionType ConditionType, severity ConditionSeverity, observedGeneration int64, reason string, message string) Condition

MakeFalseCondition makes a condition whose Status is False. A severity, reason, and message must be provided.

func (*PositiveConditionBuilder) MakeTrueCondition

func (b *PositiveConditionBuilder) MakeTrueCondition(conditionType ConditionType, observedGeneration int64) Condition

MakeTrueCondition makes a condition whose Status is True

func (*PositiveConditionBuilder) MakeUnknownCondition

func (b *PositiveConditionBuilder) MakeUnknownCondition(conditionType ConditionType, observedGeneration int64, reason string, message string) Condition

MakeUnknownCondition makes a condition whose Status is Unknown. A reason and message must be provided. No severity is required as conditions in Status Unknown do not have a known severity either.

type PositiveConditionBuilderInterface

type PositiveConditionBuilderInterface interface {
	MakeTrueCondition(conditionType ConditionType, observedGeneration int64) Condition
	MakeFalseCondition(conditionType ConditionType, severity ConditionSeverity, observedGeneration int64, reason string, message string) Condition
	MakeUnknownCondition(conditionType ConditionType, observedGeneration int64, reason string, message string) Condition
}

TODO: name?

type ReadyConditionBuilder

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

func (*ReadyConditionBuilder) Deleting

func (b *ReadyConditionBuilder) Deleting(observedGeneration int64) Condition

func (*ReadyConditionBuilder) ReadyCondition

func (b *ReadyConditionBuilder) ReadyCondition(severity ConditionSeverity, observedGeneration int64, reason string, message string) Condition

func (*ReadyConditionBuilder) Reconciling

func (b *ReadyConditionBuilder) Reconciling(observedGeneration int64) Condition

func (*ReadyConditionBuilder) Succeeded

func (b *ReadyConditionBuilder) Succeeded(observedGeneration int64) Condition

type ReadyConditionImpactingError

type ReadyConditionImpactingError struct {
	Severity ConditionSeverity
	Reason   string

	RetryClassification RetryClassification
	// contains filtered or unexported fields
}

ReadyConditionImpactingError is an error that requires notification in the Ready condition

func AsReadyConditionImpactingError

func AsReadyConditionImpactingError(err error) (*ReadyConditionImpactingError, bool)

func NewReadyConditionImpactingError

func NewReadyConditionImpactingError(cause error, severity ConditionSeverity, reason Reason) *ReadyConditionImpactingError

NewReadyConditionImpactingError creates a new ReadyConditionImpactingError

func (*ReadyConditionImpactingError) Cause

func (*ReadyConditionImpactingError) Error

func (*ReadyConditionImpactingError) Format

func (e *ReadyConditionImpactingError) Format(s fmt.State, verb rune)

This was adapted from the function in errors

func (*ReadyConditionImpactingError) Is

func (*ReadyConditionImpactingError) WithRetryClassification

func (e *ReadyConditionImpactingError) WithRetryClassification(classification RetryClassification) *ReadyConditionImpactingError

type Reason

type Reason struct {
	Name                string
	RetryClassification RetryClassification
}

func MakeReason

func MakeReason(reason string) Reason

type RetryClassification

type RetryClassification string

Jump to

Keyboard shortcuts

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