conditions

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: Apache-2.0 Imports: 8 Imported by: 21

Documentation

Index

Constants

View Source
const (
	// ControlPlaneReady is a condition type that tells if tenant cluster's
	// control plane object is in Ready condition, by mirroring Ready condition
	// from the control plane CR which is usually referenced by ControlPlaneRef
	// property in the CR Spec.
	//
	// For example, for Cluster CR it currently mirrors AzureMachine Ready
	// condition (when we start reconciling tenant cluster control plane with
	// Cluster API types, control plane type).
	//
	// Examples:
	//
	//    import capiconditions "sigs.k8s.io/cluster-api/util/conditions"
	//
	//    // Set ControlPlaneReady for Cluster CR by mirroring Ready condition
	//    // from AzureMachine CR.
	//    capiconditions.SetMirror(cluster, conditions.ControlPlaneReady, azureMachine)
	//
	//    // Set ControlPlaneReady for MachinePool CR by mirroring
	//    // Ready condition from AzureMachinePool CR.
	//    capiconditions.SetMirror(machinePool, conditions.ControlPlaneReady, azureMachinePool)
	//
	ControlPlaneReady = capi.ControlPlaneReadyCondition

	// ControlPlaneReferenceNotSetReason is a condition reason that is set when
	// ControlPlaneReady is set with status False because control plane reference
	// is not set on Cluster object. When using this reason, the condition
	// severity should be set to Warning.
	ControlPlaneReferenceNotSetReason = "ControlPlaneReferenceNotSet"

	// ControlPlaneObjectNotFoundReason is a condition reason that is set when
	// ControlPlaneReady is set with status False because control plane object
	// is not found, but control plane reference is set. When using this reason,
	// the condition severity should be set to Warning.
	ControlPlaneObjectNotFoundReason = "ControlPlaneObjectNotFound"

	// Waiting time during which ControlPlaneReady is set to False with
	// severity Info. After this threshold time, severity Warning is used.
	WaitingForControlPlaneWarningThresholdTime = 10 * time.Minute
)
View Source
const (
	// Creating is a condition type that tells if a cluster, a node pool, a
	// tenant cluster control plane, or something else that needs a Creating
	// condition is currently being created.
	Creating capi.ConditionType = "Creating"

	// CreationCompletedReason is set when the creation has been completed
	// successfully.
	CreationCompletedReason = "CreationCompleted"

	// ExistingClusterReason is used when setting a Creating condition for the
	// first time on an object that was created before conditions support was
	// implemented.
	ExistingObjectReason = "ExistingObject"
)
View Source
const (
	// InfrastructureReady is a condition type that tells if provider
	// infrastructure for the object is in Ready condition, by mirroring Ready
	// condition from the corresponding provider-specific CR which is usually
	// referenced by InfrastructureRef property in the CR Spec.
	//
	// For example, for Cluster CR it mirrors AzureCluster Ready condition and
	// for MachinePool CR it mirrors AzureMachinePool Ready condition.
	//
	// Examples:
	//
	//    import capiconditions "sigs.k8s.io/cluster-api/util/conditions"
	//
	//    // Set InfrastructureReady for Cluster CR by mirroring Ready
	//    // condition from AzureCluster CR.
	//    capiconditions.SetMirror(cluster, conditions.InfrastructureReady, azureCluster)
	//
	//    // Set InfrastructureReady for MachinePool CR by mirroring
	//    // Ready condition from AzureMachinePool CR.
	//    capiconditions.SetMirror(machinePool, conditions.InfrastructureReady, azureMachinePool)
	//
	InfrastructureReady = capi.InfrastructureReadyCondition

	// InfrastructureReferenceNotSetReason is a condition reason that is set
	// when InfrastructureReady is set with status False because object does
	// not have infrastructure reference set. When using this reason, the
	// condition severity should be set to Warning.
	InfrastructureReferenceNotSetReason = "InfrastructureReferenceNotSet"

	// InfrastructureObjectNotFoundReason is a condition reason that is set
	// when InfrastructureReady is set with status False because corresponding
	// provider-specific infrastructure object is not found, but infrastructure
	// reference is set. When using this reason, the condition severity should
	// be set to Warning.
	InfrastructureObjectNotFoundReason = "InfrastructureObjectNotFound"

	// Waiting time during which InfrastructureReady is set to False with
	// severity Info. After this threshold time, severity Warning is used.
	WaitingForInfrastructureWarningThresholdTime = 10 * time.Minute
)
View Source
const (
	// NodePoolsReady is a condition type that tells if tenant cluster node
	// pools are in Ready condition, by aggregating Ready conditions for all
	// node pool objects.
	NodePoolsReady capi.ConditionType = "NodePoolsReady"

	// NodePoolsNotFoundReason is a condition reason that is set when
	// NodePoolsReady is set with status False because node pool objects (e.g.
	// MachinePool CRs or MachineDeployment CRs) are not found.
	NodePoolsNotFoundReason = "NodePoolObjectsNotFound"
)
View Source
const (
	// Upgrading is a condition type that tells if a cluster, a node pool, a
	// tenant cluster control plane, or something else that needs an Upgrading
	// condition is currently being upgraded.
	Upgrading capi.ConditionType = "Upgrading"

	// UpgradeCompletedReason is set when the upgrade has been completed
	// successfully.
	UpgradeCompletedReason = "UpgradeCompleted"

	// UpgradeNotStartedReason is set when the upgrade has not started yet.
	// This is usually during or after creation, but can also be after
	// restoring a CR from the backup.
	UpgradeNotStartedReason = "UpgradeNotStarted"

	// UpgradePendingReason is set when the upgrade has not started yet,
	// but it is pending and it will start soon, because owner object has
	// Upgrading condition with status set to True.
	UpgradePendingReason = "UpgradePending"
)

Variables

View Source
var UnexpectedConditionStatusError = &microerror.Error{
	Kind: "UnexpectedConditionStatus",
}
View Source
var UnsupportedConditionStatusError = &microerror.Error{
	Kind: "UnsupportedConditionStatus",
}

Functions

func AreEqual

func AreEqual(c1, c2 *capi.Condition) bool

AreEqual checks if two conditions are equal (identical).

If both are nil, it returns true. If only one of them is nil, it returns false. If both are different than nil, it compares all fields: Type, Status, Severity, Reason, LastTransitionTime and Message.

func AreEquivalent

func AreEquivalent(c1, c2 *capi.Condition) bool

AreEquivalent compares specified conditions.

If both are nil, it returns true. If only one of them is nil, it returns false. If both are different than nil, it compares Type, Status, Severity and Reason fields, while it ignores LastTransitionTime and Message.

func ExpectedFalseErrorMessage

func ExpectedFalseErrorMessage(cr Object, conditionType capi.ConditionType) string

func ExpectedStatusErrorMessage

func ExpectedStatusErrorMessage(cr Object, conditionType capi.ConditionType, expectedStatus corev1.ConditionStatus) string

func ExpectedTrueErrorMessage

func ExpectedTrueErrorMessage(cr Object, conditionType capi.ConditionType) string

func GetControlPlaneReady

func GetControlPlaneReady(cluster *capi.Cluster) (capi.Condition, bool)

GetControlPlaneReady tries to get ControlPlaneReady condition from the specified Cluster CR. If the ControlPlaneReady condition was found, it returns a copy of the condition and true, otherwise it returns an empty struct and false.

func GetCreating

func GetCreating(object Object) (capi.Condition, bool)

GetCreating tries to get Creating condition from the specified object. If the Creating condition was found, it returns a copy of the condition and true, otherwise it returns an empty struct and false.

func GetInfrastructureReady

func GetInfrastructureReady(cluster *capi.Cluster) (capi.Condition, bool)

GetInfrastructureReady tries to get InfrastructureReady condition from the specified Cluster CR. If the InfrastructureReady condition was found, it returns a copy of the condition and true, otherwise it returns an empty struct and false.

func GetReplicasReady added in v0.3.0

func GetReplicasReady(machinePool *capiexp.MachinePool) (capi.Condition, bool)

GetReplicasReady tries to get ReplicasReady condition from the specified MachinePool CR. If the ReplicasReady condition was found, it returns a copy of the condition and true, otherwise it returns an empty struct and false.

func GetUpgrading

func GetUpgrading(object Object) (capi.Condition, bool)

GetUpgrading tries to get Upgrading condition from the specified object. If the Upgrading condition was found, it returns a copy of the condition and true, otherwise it returns an empty struct and false.

func IsControlPlaneReadyFalse

func IsControlPlaneReadyFalse(cluster *capi.Cluster, checkOptions ...CheckOption) bool

IsControlPlaneReadyFalse checks if specified cluster is not in ControlPlaneReady condition (if ControlPlaneReady condition is set with status False) and if optionally specified checks are successful.

func IsControlPlaneReadyTrue

func IsControlPlaneReadyTrue(cluster *capi.Cluster) bool

IsControlPlaneReadyTrue checks if specified cluster is in ControlPlaneReady condition (if ControlPlaneReady condition is set with status True).

func IsControlPlaneReadyUnknown

func IsControlPlaneReadyUnknown(cluster *capi.Cluster) bool

IsControlPlaneReadyUnknown checks if it is unknown whether the specified cluster is in ControlPlaneReady condition or not (if ControlPlaneReady condition is not set, or it is set with status Unknown).

func IsCreatingFalse

func IsCreatingFalse(object Object, checkOptions ...CheckOption) bool

IsCreatingFalse checks if specified object is not in Creating condition (if Creating condition is set with status False) and if optionally specified checks are successful.

Examples:

IsCreatingFalse(cluster)
IsCreatingFalse(cluster, WithCreationCompletedReason())
IsCreatingFalse(cluster, WithExistingObjectReason())

func IsCreatingTrue

func IsCreatingTrue(object Object) bool

IsCreatingTrue checks if specified object is in Creating condition (if Creating condition is set with status True).

func IsCreatingUnknown

func IsCreatingUnknown(object Object) bool

IsCreatingUnknown checks if it is unknown whether the specified object is in Creating condition or not (if Creating condition is not set, or it is set with status Unknown).

func IsFalse

func IsFalse(condition *capi.Condition, checkOptions ...CheckOption) bool

IsFalse checks if specified condition is not nil and has Status set to False.

func IsInfrastructureReadyFalse

func IsInfrastructureReadyFalse(object Object, checkOptions ...CheckOption) bool

IsInfrastructureReadyFalse checks if specified object is not in InfrastructureReady condition (if InfrastructureReady condition is set with status False) and if optionally specified checks are successful.

func IsInfrastructureReadyTrue

func IsInfrastructureReadyTrue(object Object) bool

IsInfrastructureReadyTrue checks if specified object is in InfrastructureReady condition (if InfrastructureReady condition is set with status True).

func IsInfrastructureReadyUnknown

func IsInfrastructureReadyUnknown(object Object) bool

IsInfrastructureReadyUnknown checks if it is unknown whether the specified object is in InfrastructureReady condition or not (if InfrastructureReady condition is not set, or it is set with status Unknown).

func IsNodePoolsReadyFalse

func IsNodePoolsReadyFalse(cluster *capi.Cluster, checkOptions ...CheckOption) bool

IsNodePoolsReadyFalse checks if specified object is not in NodePoolsReady condition (if NodePoolsReady condition is set with status False) and if optionally specified checks are successful.

func IsNodePoolsReadyTrue

func IsNodePoolsReadyTrue(cluster *capi.Cluster) bool

IsNodePoolsReadyTrue checks if specified cluster is in NodePoolsReady condition (if NodePoolsReady condition is set with status True).

func IsNodePoolsReadyUnknown

func IsNodePoolsReadyUnknown(cluster *capi.Cluster) bool

IsNodePoolsReadyUnknown checks if it is unknown whether the specified cluster is in NodePoolsReady condition or not (if NodePoolsReady condition is not set, or it is set with status Unknown).

func IsReadyFalse

func IsReadyFalse(object Object, checkOptions ...CheckOption) bool

IsReadyFalse checks if specified object is not in Ready condition (if Ready condition is set with status False).

func IsReadyTrue

func IsReadyTrue(object Object) bool

IsReadyTrue checks if specified object is in Ready condition (if Ready condition is set with status True).

func IsReadyUnknown

func IsReadyUnknown(object Object) bool

IsReadyUnknown checks if it is unknown whether the specified object is in Ready condition or not (if Ready condition is not set, or it is set with status Unknown).

func IsReplicasReadyFalse added in v0.3.0

func IsReplicasReadyFalse(machinePool *capiexp.MachinePool, checkOptions ...CheckOption) bool

IsReplicasReadyFalse checks if specified MachinePool is not in ReplicasReady condition (if ReplicasReady condition is set with status False) and if optionally specified checks are successful.

func IsReplicasReadyTrue added in v0.3.0

func IsReplicasReadyTrue(machinePool *capiexp.MachinePool) bool

IsReplicasReadyTrue checks if specified MachinePool is in ReplicasReady condition (if ReplicasReady condition is set with status True).

func IsReplicasReadyUnknown added in v0.3.0

func IsReplicasReadyUnknown(machinePool *capiexp.MachinePool) bool

IsReplicasReadyUnknown checks if it is unknown whether the specified MachinePool is in ReplicasReady condition or not (if ReplicasReady condition is not set, or it is set with status Unknown).

func IsTrue

func IsTrue(condition *capi.Condition) bool

IsTrue checks if specified condition is not nil and has Status set to True.

func IsUnexpectedConditionStatus

func IsUnexpectedConditionStatus(err error) bool

IsUnexpectedConditionStatus asserts UnexpectedConditionStatusError.

func IsUnknown

func IsUnknown(condition *capi.Condition) bool

IsUnknown checks if specified condition is either nil or has Status set to Unknown.

func IsUnsupported

func IsUnsupported(from capiconditions.Getter, t capi.ConditionType) bool

func IsUnsupportedConditionStatus

func IsUnsupportedConditionStatus(err error) bool

IsInvalidCondition asserts invalidConditionError.

func IsUpgradingFalse

func IsUpgradingFalse(object Object, checkOptions ...CheckOption) bool

IsUpgradingFalse checks if specified object is not in Upgrading condition (if Upgrading condition is set with status False) and if optionally specified checks are successful.

Examples:

IsUpgradingFalse(cluster)
IsUpgradingFalse(cluster, WithUpgradeCompletedReason())
IsUpgradingFalse(cluster, WithUpgradeNotStartedReason())

func IsUpgradingTrue

func IsUpgradingTrue(object Object) bool

IsUpgradingTrue checks if specified object is in Upgrading condition (if Upgrading condition is set with status True).

func IsUpgradingUnknown

func IsUpgradingUnknown(object Object) bool

IsUpgradingUnknown checks if it is unknown whether the specified object is in Upgrading condition or not (if Upgrading condition is not set, or it is set with status Unknown).

func UnexpectedConditionStatusErrorMessage

func UnexpectedConditionStatusErrorMessage(cr Object, t capi.ConditionType) string

func UnsupportedConditionStatusErrorMessage

func UnsupportedConditionStatusErrorMessage(cr Object, t capi.ConditionType) string

Types

type CheckOption

type CheckOption func(condition *capi.Condition) bool

func WithCreationCompletedReason

func WithCreationCompletedReason() CheckOption

WithCreationCompletedReason returns a CheckOption that checks if condition reason is set to CreationCompleted.

func WithExistingObjectReason

func WithExistingObjectReason() CheckOption

WithExistingObjectReason returns a CheckOption that checks if condition reason is set to ExistingObject.

func WithReason

func WithReason(reason string) CheckOption

WithReason returns a CheckOption that checks if condition reason is set to the specified value.

func WithSeverity

func WithSeverity(severity capi.ConditionSeverity) CheckOption

WithSeverity returns a CheckOption that checks if condition severity is set to the specified value.

func WithSeverityError

func WithSeverityError() CheckOption

WithSeverityError returns a CheckOption that checks if condition severity is set to Error.

func WithSeverityInfo

func WithSeverityInfo() CheckOption

WithSeverityInfo returns a CheckOption that checks if condition severity is set to Info.

func WithSeverityWarning

func WithSeverityWarning() CheckOption

WithSeverityWarning returns a CheckOption that checks if condition severity is set to Warning.

func WithUpgradeCompletedReason

func WithUpgradeCompletedReason() CheckOption

WithUpgradeCompletedReason returns a CheckOption that checks if condition reason is set to UpgradeCompleted.

func WithUpgradeNotStartedReason

func WithUpgradeNotStartedReason() CheckOption

WithUpgradeNotStartedReason returns a CheckOption that checks if condition reason is set to UpgradeNotStarted.

func WithWaitingForReplicasReadyReason added in v0.3.0

func WithWaitingForReplicasReadyReason() CheckOption

WithWaitingForReplicasReadyReason returns a CheckOption that checks if condition reason is set to WaitingForReplicasReady.

func WithoutSeverity

func WithoutSeverity() CheckOption

WithoutSeverity returns a CheckOption that checks if condition severity is not set.

type Object

type Object interface {
	capiconditions.Setter
	metav1.Object
}

Jump to

Keyboard shortcuts

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