condition

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package condition provides condition related utils.

Index

Constants

View Source
const (
	// RolloutStartedUnknownReason is the reason string of placement condition if rollout status is
	// unknown.
	RolloutStartedUnknownReason = "RolloutStartedUnknown"

	// RolloutNotStartedYetReason is the reason string of placement condition if the rollout has not started yet.
	RolloutNotStartedYetReason = "RolloutNotStartedYet"

	// RolloutStartedReason is the reason string of placement condition if rollout status is started.
	RolloutStartedReason = "RolloutStarted"

	// OverriddenPendingReason is the reason string of placement condition when the selected resources are pending to override.
	OverriddenPendingReason = "OverriddenPending"

	// OverrideNotSpecifiedReason is the reason string of placement condition when no override is specified.
	OverrideNotSpecifiedReason = "NoOverrideSpecified"

	// OverriddenFailedReason is the reason string of placement condition when the selected resources fail to be overridden.
	OverriddenFailedReason = "OverriddenFailed"

	// OverriddenSucceededReason is the reason string of placement condition when the selected resources are overridden successfully.
	OverriddenSucceededReason = "OverriddenSucceeded"

	// WorkSynchronizedUnknownReason is the reason string of placement condition when the work is pending to be created
	// or updated.
	WorkSynchronizedUnknownReason = "WorkSynchronizedUnknown"

	// WorkNotSynchronizedYetReason is the reason string of placement condition when not all corresponding works are created
	// or updated in the target cluster's namespace yet.
	WorkNotSynchronizedYetReason = "WorkNotSynchronizedYet"

	// WorkSynchronizedReason is the reason string of placement condition when all corresponding works are created or updated
	// in the target cluster's namespace successfully.
	WorkSynchronizedReason = "WorkSynchronized"

	// ApplyPendingReason is the reason string of placement condition when the selected resources are pending to apply.
	ApplyPendingReason = "ApplyPending"

	// ApplyFailedReason is the reason string of placement condition when the selected resources fail to apply.
	ApplyFailedReason = "ApplyFailed"

	// ApplySucceededReason is the reason string of placement condition when the selected resources are applied successfully.
	ApplySucceededReason = "ApplySucceeded"

	// AvailableUnknownReason is the reason string of placement condition when the availability of selected resources
	// is unknown.
	AvailableUnknownReason = "ResourceAvailableUnknown"

	// NotAvailableYetReason is the reason string of placement condition if the selected resources are not available yet.
	NotAvailableYetReason = "ResourceNotAvailableYet"

	// AvailableReason is the reason string of placement condition if the selected resources are available.
	AvailableReason = "ResourceAvailable"

	// DiffReportedStatusUnknownReason is the reason string of the DiffReported condition when the
	// diff reporting has just started and its status is not yet to be known.
	DiffReportedStatusUnknownReason = "DiffReportingPending"

	// DiffReportedStatusFalseReason is the reason string of the DiffReported condition when the
	// diff reporting has not been fully completed.
	DiffReportedStatusFalseReason = "DiffReportingIncompleteOrFailed"

	// DiffReportedStatusTrueReason is the reason string of the DiffReported condition when the
	// diff reporting has been fully completed.
	DiffReportedStatusTrueReason = "DiffReportingCompleted"
)

A group of condition reason string which is used to populate the placement condition.

View Source
const (
	// ScheduleSucceededReason is the reason string of placement condition if scheduling succeeded.
	ScheduleSucceededReason = "Scheduled"

	// AllWorkSyncedReason is the reason string of placement condition if all works are synchronized.
	AllWorkSyncedReason = "AllWorkSynced"

	// SyncWorkFailedReason is the reason string of placement condition if some works failed to synchronize.
	SyncWorkFailedReason = "SyncWorkFailed"

	// WorkApplyInProcess is the reason string of placement condition if works are just synchronized and in the process of being applied.
	WorkApplyInProcess = "ApplyInProgress"

	// WorkDiffReportInProcess is the reason string of placement condition if works are just synchronized and diff reporting is in progress.
	WorkDiffReportInProcess = "DiffReportInProgress"

	// WorkNotAppliedReason is the reason string of placement condition if some works are not applied.
	WorkNotAppliedReason = "NotAllWorkHaveBeenApplied"

	// AllWorkAppliedReason is the reason string of placement condition if all works are applied.
	AllWorkAppliedReason = "AllWorkHaveBeenApplied"

	// WorkNotAvailableReason is the reason string of placement condition if some works are not available.
	WorkNotAvailableReason = "NotAllWorkAreAvailable"

	// AllWorkAvailableReason is the reason string of placement condition if all works are available.
	AllWorkAvailableReason = "AllWorkAreAvailable"

	// AllWorkDiffReportedReason is the reason string of placement condition if all works have diff reported.
	AllWorkDiffReportedReason = "AllWorkHaveDiffReported"

	// WorkNotDiffReportedReason is the reason string of placement condition if some works failed to have diff reported.
	WorkNotDiffReportedReason = "NotAllWorkHaveDiffReported"
)

A group of condition reason string which is used to populate the placement condition per cluster.

View Source
const (
	// UpdateRunInitializeSucceededReason is the reason string of condition if the update run is initialized successfully.
	UpdateRunInitializeSucceededReason = "UpdateRunInitializedSuccessfully"

	// UpdateRunInitializeFailedReason is the reason string of condition if the update run is failed to initialize.
	UpdateRunInitializeFailedReason = "UpdateRunInitializedFailed"

	// UpdateRunStartedReason is the reason string of condition if the staged update run has started.
	UpdateRunStartedReason = "UpdateRunStarted"

	// UpdateRunFailedReason is the reason string of condition if the staged update run failed.
	UpdateRunFailedReason = "UpdateRunFailed"

	// UpdateRunSucceededReason is the reason string of condition if the staged update run succeeded.
	UpdateRunSucceededReason = "UpdateRunSucceeded"

	// StageUpdatingStartedReason is the reason string of condition if the stage updating has started.
	StageUpdatingStartedReason = "StageUpdatingStarted"

	// StageUpdatingWaitingReason is the reason string of condition if the stage updating is waiting.
	StageUpdatingWaitingReason = "StageUpdatingWaiting"

	// StageUpdatingFailedReason is the reason string of condition if the stage updating failed.
	StageUpdatingFailedReason = "StageUpdatingFailed"

	// StageUpdatingSucceededReason is the reason string of condition if the stage updating succeeded.
	StageUpdatingSucceededReason = "StageUpdatingSucceeded"

	// ClusterUpdatingStartedReason is the reason string of condition if the cluster updating has started.
	ClusterUpdatingStartedReason = "ClusterUpdatingStarted"

	// ClusterUpdatingFailedReason is the reason string of condition if the cluster updating failed.
	ClusterUpdatingFailedReason = "ClusterUpdatingFailed"

	// ClusterUpdatingSucceededReason is the reason string of condition if the cluster updating succeeded.
	ClusterUpdatingSucceededReason = "ClusterUpdatingSucceeded"

	// AfterStageTaskApprovalRequestApprovedReason is the reason string of condition if the approval request for after stage task has been approved.
	AfterStageTaskApprovalRequestApprovedReason = "AfterStageTaskApprovalRequestApproved"

	// AfterStageTaskApprovalRequestCreatedReason is the reason string of condition if the approval request for after stage task has been created.
	AfterStageTaskApprovalRequestCreatedReason = "AfterStageTaskApprovalRequestCreated"

	// AfterStageTaskWaitTimeElapsedReason is the reason string of condition if the wait time for after stage task has elapsed.
	AfterStageTaskWaitTimeElapsedReason = "AfterStageTaskWaitTimeElapsed"

	// ApprovalRequestApprovalAcceptedReason is the reason string of condition if the approval of the approval request has been accepted.
	ApprovalRequestApprovalAcceptedReason = "ApprovalRequestApprovalAccepted"
)

A group of condition reason string which is used t populate the ClusterStagedUpdateRun condition.

View Source
const (
	// ClusterResourcePlacementEvictionValidReason is the reason string of condition if the eviction is valid.
	ClusterResourcePlacementEvictionValidReason = "ClusterResourcePlacementEvictionValid"

	// ClusterResourcePlacementEvictionInvalidReason is the reason string of condition if the eviction is invalid.
	ClusterResourcePlacementEvictionInvalidReason = "ClusterResourcePlacementEvictionInvalid"

	// ClusterResourcePlacementEvictionExecutedReason is the reason string of condition if the eviction is executed.
	ClusterResourcePlacementEvictionExecutedReason = "ClusterResourcePlacementEvictionExecuted"

	// ClusterResourcePlacementEvictionNotExecutedReason is the reason string of condition if the eviction is not executed.
	ClusterResourcePlacementEvictionNotExecutedReason = "ClusterResourcePlacementEvictionNotExecuted"

	// EvictionInvalidMissingCRPMessage is the message string of invalid eviction condition when CRP is missing.
	EvictionInvalidMissingCRPMessage = "Failed to find ClusterResourcePlacement targeted by eviction"

	// EvictionInvalidDeletingCRPMessage is the message string of invalid eviction condition when CRP is deleting.
	EvictionInvalidDeletingCRPMessage = "Found deleting ClusterResourcePlacement targeted by eviction"

	// EvictionInvalidPickFixedCRPMessage is the message string of invalid eviction condition when CRP placement type is PickFixed.
	EvictionInvalidPickFixedCRPMessage = "Found ClusterResourcePlacement with PickFixed placement type targeted by eviction"

	// EvictionInvalidMissingCRBMessage is the message string of invalid eviction condition when CRB is missing.
	EvictionInvalidMissingCRBMessage = "Failed to find scheduler decision for placement in cluster targeted by eviction"

	// EvictionInvalidMultipleCRBMessage is the message string of invalid eviction condition when more than one CRB is present for cluster targeted by eviction.
	EvictionInvalidMultipleCRBMessage = "Found more than one scheduler decision for placement in cluster targeted by eviction"

	// EvictionValidMessage is the message string of valid eviction condition.
	EvictionValidMessage = "Eviction is valid"

	// EvictionAllowedNoPDBMessage is the message string for executed condition when no PDB is specified.
	EvictionAllowedNoPDBMessage = "Eviction is allowed, no ClusterResourcePlacementDisruptionBudget specified"

	// EvictionAllowedPlacementRemovedMessage is the message string for executed condition when CRB targeted by eviction is being deleted.
	EvictionAllowedPlacementRemovedMessage = "Eviction is allowed, resources propagated by placement is currently being removed from cluster targeted by eviction"

	// EvictionAllowedPlacementFailedMessage is the message string for executed condition when placed resources have failed to apply or the resources are not available.
	EvictionAllowedPlacementFailedMessage = "Eviction is allowed, placement has failed"

	// EvictionBlockedMisconfiguredPDBSpecifiedMessage is the message string for not executed condition when PDB specified is misconfigured for PickAll CRP.
	EvictionBlockedMisconfiguredPDBSpecifiedMessage = "" /* 195-byte string literal not displayed */

	// EvictionBlockedMissingPlacementMessage is the message string for not executed condition when resources are yet to be placed in targeted cluster by eviction.
	EvictionBlockedMissingPlacementMessage = "Eviction is blocked, placement has not propagated resources to target cluster yet"

	// EvictionAllowedPDBSpecifiedMessageFmt is the message format for executed condition when eviction is allowed by PDB specified.
	EvictionAllowedPDBSpecifiedMessageFmt = "Eviction is allowed by specified ClusterResourcePlacementDisruptionBudget, availablePlacements: %d, totalPlacements: %d"

	// EvictionBlockedPDBSpecifiedMessageFmt is the message format for not executed condition when eviction is blocked bt PDB specified.
	EvictionBlockedPDBSpecifiedMessageFmt = "Eviction is blocked by specified ClusterResourcePlacementDisruptionBudget, availablePlacements: %d, totalPlacements: %d"
)

A group of condition reason & message string which is used to populate the ClusterResourcePlacementEviction condition.

View Source
const (
	UnknownConditionStatus conditionStatus = iota
	FalseConditionStatus
	TrueConditionStatus
	TotalConditionStatus
)

Variables

View Source
var (
	// Different set of condition types that Fleet will populate in sequential order based on the
	// apply strategy in use.
	CondTypesForClientSideServerSideApplyStrategies = []ResourceCondition{
		RolloutStartedCondition,
		OverriddenCondition,
		WorkSynchronizedCondition,
		AppliedCondition,
		AvailableCondition,
	}

	CondTypesForReportDiffApplyStrategy = []ResourceCondition{
		RolloutStartedCondition,
		OverriddenCondition,
		WorkSynchronizedCondition,
		DiffReportedCondition,
	}
)

Functions

func EqualCondition

func EqualCondition(current, desired *metav1.Condition) bool

EqualCondition compares one condition with another; it ignores the LastTransitionTime and Message fields, and will consider the ObservedGeneration values from the two conditions a match if the current condition is newer.

func EqualConditionIgnoreReason

func EqualConditionIgnoreReason(current, desired *metav1.Condition) bool

EqualConditionIgnoreReason compares one condition with another; it ignores the Reason, LastTransitionTime, and Message fields, and will consider the ObservedGeneration values from the two conditions a match if the current condition is newer.

func IsConditionStatusFalse added in v0.7.11

func IsConditionStatusFalse(cond *metav1.Condition, latestGeneration int64) bool

IsConditionStatusFalse returns true if the condition is false and the observed generation matches the latest generation.

func IsConditionStatusTrue added in v0.6.8

func IsConditionStatusTrue(cond *metav1.Condition, latestGeneration int64) bool

IsConditionStatusTrue returns true if the condition is true and the observed generation matches the latest generation.

Types

type ResourceCondition added in v0.9.8

type ResourceCondition int

ResourceCondition is all the resource related condition, for example, scheduled condition is not included.

const (
	RolloutStartedCondition ResourceCondition = iota
	OverriddenCondition
	WorkSynchronizedCondition
	AppliedCondition
	AvailableCondition
	DiffReportedCondition
	TotalCondition
)

The full set of condition types that Fleet will populate on CRPs (the CRP itself and the resource placement status per cluster) and cluster resource bindings.

  • RolloutStarted, Overridden and WorkSynchronized apply to all objects;
  • Applied and Available apply only when the apply strategy in use is of the ClientSideApply and ServerSideApply type;
  • DiffReported applies only the apply strategy in use is of the ReportDiff type.
  • Total is a end marker (not used).

func (ResourceCondition) ClusterResourcePlacementConditionType added in v0.9.8

func (c ResourceCondition) ClusterResourcePlacementConditionType() fleetv1beta1.ClusterResourcePlacementConditionType

ClusterResourcePlacementConditionType returns the CRP condition type used by CRP.

func (ResourceCondition) EventMessageForTrue added in v0.9.8

func (c ResourceCondition) EventMessageForTrue() string

func (ResourceCondition) EventReasonForTrue added in v0.9.8

func (c ResourceCondition) EventReasonForTrue() string

func (ResourceCondition) FalseClusterResourcePlacementCondition added in v0.9.8

func (c ResourceCondition) FalseClusterResourcePlacementCondition(generation int64, clusterCount int) metav1.Condition

FalseClusterResourcePlacementCondition returns the false cluster resource placement condition.

func (ResourceCondition) ResourceBindingConditionType added in v0.9.8

func (c ResourceCondition) ResourceBindingConditionType() fleetv1beta1.ResourceBindingConditionType

ResourceBindingConditionType returns the binding condition type used by cluster resource binding.

func (ResourceCondition) ResourcePlacementConditionType added in v0.9.8

func (c ResourceCondition) ResourcePlacementConditionType() fleetv1beta1.ResourcePlacementConditionType

ResourcePlacementConditionType returns the resource condition type per cluster used by cluster resource placement.

func (ResourceCondition) TrueClusterResourcePlacementCondition added in v0.9.8

func (c ResourceCondition) TrueClusterResourcePlacementCondition(generation int64, clusterCount int) metav1.Condition

TrueClusterResourcePlacementCondition returns the true cluster resource placement condition.

func (ResourceCondition) UnknownClusterResourcePlacementCondition added in v0.9.8

func (c ResourceCondition) UnknownClusterResourcePlacementCondition(generation int64, clusterCount int) metav1.Condition

UnknownClusterResourcePlacementCondition returns the unknown cluster resource placement condition.

func (ResourceCondition) UnknownResourceConditionPerCluster added in v0.9.8

func (c ResourceCondition) UnknownResourceConditionPerCluster(generation int64) metav1.Condition

UnknownResourceConditionPerCluster returns the unknown resource condition.

Jump to

Keyboard shortcuts

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