condition

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 74

Documentation

Index

Constants

View Source
const (
	// RequestedReason (Severity=Info) documents a condition not in Status=True because the underlying object is not ready.
	RequestedReason = "Requested"

	// NotRequestedReason (Severity=Info) documents a condition not in
	// Status=True because the underlying object has not yet been requested
	NotRequestedReason = "NotRequested"

	// CreationFailedReason (Severity=Error) documents a condition not in Status=True because the underlying object failed.
	CreationFailedReason = "CreationFailed"

	// ReadyReason documents a condition in `Status=True` when requested resource is ready.
	ReadyReason = "Ready"

	// InitReason documents a condition in `Status=Unknown` when reconcilation started.
	InitReason = "Init"

	// ErrorReason (Severity=Warning) documents a condition not in Status=True because the underlying object failed.
	// This is a warning because the reconciler will retry deletion.
	ErrorReason = "Error"

	// JobReasonBackoffLimitExceeded (Severity=Error) documents a condition not in Status=True because the underlying object reached the backoff limit.
	// This is an error because the reconciler won't retry anymore.
	JobReasonBackoffLimitExceeded = "BackoffLimitExceeded"

	// DeletingReason (Severity=Info) documents a condition not in Status=True because the underlying object it is currently being deleted.
	DeletingReason = "Deleting"

	// DeletionFailedReason (Severity=Warning) documents a condition not in Status=True because the underlying object
	// encountered problems during deletion. This is a warning because the reconciler will retry deletion.
	DeletionFailedReason = "DeletionFailed"

	// DeletedReason (Severity=Info) documents a condition not in Status=True because the underlying object was deleted.
	DeletedReason = "Deleted"
)

Common Reasons used by API objects.

View Source
const (
	//
	// Overall Ready Condition messages
	//
	// ReadyInitMessage
	ReadyInitMessage = "Setup started"

	// ReadyMessage
	ReadyMessage = "Setup complete"

	//
	// InputReady condition messages
	//
	// InputReadyInitMessage
	InputReadyInitMessage = "Input data not checked"

	// InputReadyMessage
	InputReadyMessage = "Input data complete"

	// InputReadyWaiting
	InputReadyWaitingMessage = "Input data resources missing"

	// InputReadyErrorMessage
	InputReadyErrorMessage = "Input data error occurred %s"

	//
	// ServiceConfig condition messages
	//
	// ServiceConfigReadyInitMessage
	ServiceConfigReadyInitMessage = "Service config create not started"

	// ServiceConfigReadyMessage
	ServiceConfigReadyMessage = "Service config create completed"

	// ServiceConfigReadyErrorMessage
	ServiceConfigReadyErrorMessage = "Service config create error occurred %s"

	//
	// DBReady condition messages
	//
	// DBReadyInitMessage
	DBReadyInitMessage = "DB create not started"

	// DBReadyMessage
	DBReadyMessage = "DB create completed"

	// DBReadyRunningMessage
	DBReadyRunningMessage = "DB create job still running"

	// DBReadyErrorMessage
	DBReadyErrorMessage = "DB create job error occurred %s"

	//
	// DBSync condition messages
	//
	// DBSyncReadyInitMessage
	DBSyncReadyInitMessage = "DBsync not started"

	// DBSyncReadyMessage
	DBSyncReadyMessage = "DBsync completed"

	// DBSyncReadyRunning
	DBSyncReadyRunningMessage = "DBsync job still running"

	// DBSyncReadyErrorMessage
	DBSyncReadyErrorMessage = "DBsync job error occurred %s"

	//
	// ExposeService condition messages
	//
	// ExposeServiceReadyInitMessage
	ExposeServiceReadyInitMessage = "Exposing service not started"

	// ExposeServiceReadyMessage
	ExposeServiceReadyMessage = "Exposing service completed"

	// ExposeServiceReadyRunningMessage
	ExposeServiceReadyRunningMessage = "Exposing service in progress"

	// ExposeServiceReadyErrorMessage
	ExposeServiceReadyErrorMessage = "Exposing service error occurred %s"

	//
	// BootstrapReady condition messages
	//
	// BootstrapReadyInitMessage
	BootstrapReadyInitMessage = "Bootstrap not started"

	// BootstrapReadyMessage
	BootstrapReadyMessage = "Bootstrap completed"

	// BootstrapReadyRunningMessage
	BootstrapReadyRunningMessage = "Bootstrap in progress"

	// BootstrapReadyErrorMessage
	BootstrapReadyErrorMessage = "Bootstrap error occurred %s"

	//
	// DeploymentReady condition messages
	//
	// DeploymentReadyInitMessage
	DeploymentReadyInitMessage = "Deployment not started"

	// DeploymentReadyMessage
	DeploymentReadyMessage = "Deployment completed"

	// DeploymentReadyRunningMessage
	DeploymentReadyRunningMessage = "Deployment in progress"

	// DeploymentReadyErrorMessage
	DeploymentReadyErrorMessage = "Deployment error occurred %s"

	//
	// NetworkAttachmentsReady condition messages
	//
	// NetworkAttachmentsReadyInitMessage
	NetworkAttachmentsReadyInitMessage = "NetworkAttachments not started"

	// NetworkAttachmentsReadyMessage
	NetworkAttachmentsReadyMessage = "NetworkAttachments completed"

	// NetworkAttachmentsReadyWaitingMessage
	NetworkAttachmentsReadyWaitingMessage = "NetworkAttachment resources missing: %s"

	// NetworkAttachmentsReadyErrorMessage
	NetworkAttachmentsReadyErrorMessage = "NetworkAttachments error occurred %s"

	//
	// CronJobReady condition messages
	//
	// CronJobReadyInitMessage
	CronJobReadyInitMessage = "CronJob not started"

	// CronJobReadyMessage
	CronJobReadyMessage = "CronJob completed"

	// CronJobReadyErrorMessage
	CronJobReadyErrorMessage = "CronJob error occurred %s"

	//
	// JobReady condition messages
	//
	// JobReadyInitMessage
	JobReadyInitMessage = "Job not started"

	// JobReadyMessage
	JobReadyMessage = "Job completed"

	// JobReadyRunningMessage
	JobReadyRunningMessage = "Job in progress"

	// JobReadyErrorMessage
	JobReadyErrorMessage = "Job error occurred %s"

	//
	// MemcachedReady condition messages
	//
	// MemcachedReadyInitMessage -
	MemcachedReadyInitMessage = " Memcached create not started"

	// MemcachedReadyMessage - Provides the message to clarify memcached has been provisioned
	MemcachedReadyMessage = " Memcached instance has been provisioned"

	// MemcachedReadyWaitingMessage - Provides the message to clarify memcached has not been provisioned
	MemcachedReadyWaitingMessage = " Memcached instance has not been provisioned"

	// MemcachedReadyErrorMessage -
	MemcachedReadyErrorMessage = " Memcached error occurred %s"

	//
	// RabbitMqTransportURLReady condition messages
	//
	// RabbitMqTransportURLReadyInitMessage
	RabbitMqTransportURLReadyInitMessage = "RabbitMqTransportURL not started"

	// RabbitMqTransportURLReadyRunningMessage
	RabbitMqTransportURLReadyRunningMessage = "RabbitMqTransportURL creation in progress"

	// RabbitMqTransportURLReadyMessage
	RabbitMqTransportURLReadyMessage = "RabbitMqTransportURL successfully created"

	// RabbitMqTransportURLReadyErrorMessage
	RabbitMqTransportURLReadyErrorMessage = "RabbitMqTransportURL error occured %s"

	//
	// AnsibleEEReady condition messages
	//
	// AnsibleEEReadyInitMessage
	AnsibleEEReadyInitMessage = "AnsibleEE not started"

	// AnsibleEEReadyMessage
	AnsibleEEReadyMessage = "AnsibleEE completed"

	// AnsibleEEReadyRunningMessage
	AnsibleEEReadyRunningMessage = "AnsibleEE in progress"

	// AnsibleEEReadyErrorMessage
	AnsibleEEReadyErrorMessage = "AnsibleEE error occurred %s"

	//
	// TLSInputReady condition messages
	//
	// TLSInputReadyWaitingMessage - Provides the message to clarify that TLS resources have not been generated yet
	TLSInputReadyWaitingMessage = "TLSInput is missing: %s"

	// TLSInputErrorMessage - Provides the message when there's error in provision of TLS sources
	TLSInputErrorMessage = "TLSInput error occured in TLS sources %s"
)

Common Messages used by API objects.

View Source
const (
	// ServiceAccountReadyErrorMessage
	ServiceAccountReadyErrorMessage = "ServiceAccount error occurred %s"

	// ServiceAccountCreatingMessage
	ServiceAccountCreatingMessage = "ServiceAccount creation in progress"

	// ServiceAccountReadyInitMessage
	ServiceAccountReadyInitMessage = "ServiceAccount not created"

	// ServiceAccountReadyMessage
	ServiceAccountReadyMessage = "ServiceAccount created"

	// RoleReadyErrorMessage
	RoleReadyErrorMessage = "Role error occurred %s"

	// RoleCreatingMessage
	RoleCreatingMessage = "Role creation in progress"

	// RoleReadyInitMessage
	RoleReadyInitMessage = "Role not created"

	// RoleReadyMessage
	RoleReadyMessage = "Role created"

	// RoleBindingReadyErrorMessage
	RoleBindingReadyErrorMessage = "RoleBinding error occurred %s"

	// RoleBindingCreatingMessage
	RoleBindingCreatingMessage = "RoleBinding creation in progress"

	// RoleBindingReadyInitMessage
	RoleBindingReadyInitMessage = "RoleBinding not created"

	// RoleBindingReadyMessage
	RoleBindingReadyMessage = "RoleBinding created"
)

Common Messages used for service accounts, roles, role bindings

Variables

This section is empty.

Functions

func HasSameState added in v0.4.0

func HasSameState(i, j *Condition) bool

HasSameState returns true if a condition has the same state of another

func IsError

func IsError(condition *Condition) bool

IsError is True if the condition is a) not nil, b) status=False and c) condition.Reason is condition.ErrorReason or condition.JobReasonBackoffLimitExceeded, otherwise it returns False if the condition is not True or if the condition does not exist (is nil).

func RestoreLastTransitionTimes added in v0.4.0

func RestoreLastTransitionTimes(conditions *Conditions, savedConditions Conditions)

RestoreLastTransitionTimes - Updates each condition's LastTransitionTime when its state matches the one in a list of "saved" conditions.

Types

type Condition

type Condition struct {
	// Type of condition in CamelCase.
	Type Type `json:"type"`

	// Status of the condition, one of True, False, Unknown.
	Status corev1.ConditionStatus `json:"status"`

	// Severity provides a classification of Reason code, so the current situation is immediately
	// understandable and could act accordingly.
	// It is meant for situations where Status=False and it should be indicated if it is just
	// informational, warning (next reconciliation might fix it) or an error (e.g. DB create issue
	// and no actions to automatically resolve the issue can/should be done).
	// For conditions where Status=Unknown or Status=True the Severity should be SeverityNone.
	Severity Severity `json:"severity,omitempty"`

	// Last time the condition transitioned from one status to another.
	// This should be when the underlying condition changed. If that is not known, then using the time when
	// the API field changed is acceptable.
	LastTransitionTime metav1.Time `json:"lastTransitionTime"`

	// The reason for the condition's last transition in CamelCase.
	Reason Reason `json:"reason,omitempty"`

	// A human readable message indicating details about the transition.
	// +optional
	Message string `json:"message,omitempty"`
}

Condition defines an observation of a API resource operational state.

func FalseCondition

func FalseCondition(t Type, reason Reason, severity Severity, messageFormat string, messageArgs ...interface{}) *Condition

FalseCondition returns a condition with Status=False and the given type.

func GetHigherPrioCondition

func GetHigherPrioCondition(cond1, cond2 *Condition) *Condition

GetHigherPrioCondition validates the priority of two conditions based on groupOrder(c) and returns the one which has precedence of the other. If one of them is nil, the non nil get returned. If both of them have the same priority the one with the later LastTransitionTime gets returned.

func TrueCondition

func TrueCondition(t Type, messageFormat string, messageArgs ...interface{}) *Condition

TrueCondition returns a condition with Status=True and the given type.

func UnknownCondition

func UnknownCondition(t Type, reason Reason, messageFormat string, messageArgs ...interface{}) *Condition

UnknownCondition returns a condition with Status=Unknown and the given type.

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.

type Conditions

type Conditions []Condition

Conditions provide observations of the operational state of a API resource.

func CreateList

func CreateList(conditions ...*Condition) Conditions

CreateList returns a conditions from a parameter list of several conditions.

func (*Conditions) AllSubConditionIsTrue

func (conditions *Conditions) AllSubConditionIsTrue() bool

AllSubConditionIsTrue validates if all subconditions are True It assumes that all conditions report success via the True status

func (Conditions) DeepCopy

func (in Conditions) DeepCopy() Conditions

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

func (Conditions) DeepCopyInto

func (in Conditions) DeepCopyInto(out *Conditions)

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

func (*Conditions) Get

func (conditions *Conditions) Get(t Type) *Condition

Get returns the condition with the given type, if the condition does not exists, it returns nil.

func (*Conditions) Has

func (conditions *Conditions) Has(t Type) bool

Has returns true if a condition with the given type exists.

func (*Conditions) Init

func (conditions *Conditions) Init(cl *Conditions)

Init - init new condition list with the overall ReadyCondition set to: Type: ReadyCondition, Status: Unknown, Reason, Severity and Message.

Optional conditions list can be passed as parameter which allows to initialize additional conditions at the beginning.

func (*Conditions) IsFalse

func (conditions *Conditions) IsFalse(t Type) bool

IsFalse is true if the condition with the given type is False, otherwise it return false if the condition is not False or if the condition does not exist (is nil).

func (*Conditions) IsTrue

func (conditions *Conditions) IsTrue(t Type) bool

IsTrue is true if the condition with the given type is True, otherwise it return false if the condition is not True or if the condition does not exist (is nil).

func (*Conditions) IsUnknown

func (conditions *Conditions) IsUnknown(t Type) bool

IsUnknown is true if the condition with the given type is Unknown or if the condition does not exist (is nil).

func (*Conditions) MarkFalse

func (conditions *Conditions) MarkFalse(t Type, reason Reason, severity Severity, messageFormat string, messageArgs ...interface{})

MarkFalse sets Status=False for the condition with the given type.

func (*Conditions) MarkTrue

func (conditions *Conditions) MarkTrue(t Type, messageFormat string, messageArgs ...interface{})

MarkTrue sets Status=True for the condition with the given type.

func (*Conditions) MarkUnknown

func (conditions *Conditions) MarkUnknown(t Type, reason Reason, messageFormat string, messageArgs ...interface{})

MarkUnknown sets Status=Unknown for the condition with the given type.

func (*Conditions) Mirror

func (conditions *Conditions) Mirror(t Type) *Condition

Mirror - mirrors Status, Message, Reason and Severity from the latest condition of a sorted conditionGroup list into a target condition of type t. If the top level ReadyCondition is True then it is assumed that there are no False or important Uknown conditions present in the list as ReadyCondition is expected to be an aggregated status condition. If ReadyCondition is not True then the conditionGroup entries are split by Status with the order False, Unknown, True. If Status=False its again split into Severity with the order Error, Warning, Info. So Mirror either reflects the ReadyCondition=True or reflects the latest most sever False or Uknown condition.

func (*Conditions) Remove

func (conditions *Conditions) Remove(t Type)

Remove a condition from the slice of conditions

func (*Conditions) Set

func (conditions *Conditions) Set(c *Condition)

Set - sets new condition on the conditions list.

If a condition already exists, the LastTransitionTime is only updated when there is a change in any of the fields: Status, Reason, Severity and Message.

The conditons list get sorted so that the Ready condition always goes first, followed by all the other Member conditions sorted by Type. This makes it easy to identify the overall state of the service

func (*Conditions) Sort

func (conditions *Conditions) Sort()

Sort - Sorts the list so that the Ready condition always goes first, followed by all the other conditions sorted by Type. This makes it easy to identify the overall state of the service

func (*Conditions) SortByLastTransitionTime

func (conditions *Conditions) SortByLastTransitionTime()

SortByLastTransitionTime - Sorts a list of conditions by the LastTransitionTime

type Reason

type Reason string

Reason - Why a particular condition is true, false or unknown

type Severity

type Severity string

Severity expresses the severity of a Condition Type failing.

const (
	// SeverityError specifies that a condition with `Status=False` is an error.
	SeverityError Severity = "Error"

	// SeverityWarning specifies that a condition with `Status=False` is a warning.
	SeverityWarning Severity = "Warning"

	// SeverityInfo specifies that a condition with `Status=False` is informative.
	SeverityInfo Severity = "Info"

	// SeverityNone should apply only to conditions with `Status=True`.
	SeverityNone Severity = ""
)

type Type

type Type string

Type - A summarizing name for a given condition

const (
	// ReadyCondition defines the Ready condition type that summarizes the operational state of an API object.
	ReadyCondition Type = "Ready"

	// InputReadyCondition Status=True condition which indicates if all required input sources are available, like e.g. secret holding passwords, other config maps providing input for the service.
	InputReadyCondition Type = "InputReady"

	// ServiceConfigReadyCondition Status=True Condition which indicates that all service config got rendered ok from the templates and stored in the ConfigMap
	ServiceConfigReadyCondition Type = "ServiceConfigReady"

	// DBReadyCondition Status=True condition is mirrored from the Ready condition in the mariadbdatabase ref object to the service API.
	DBReadyCondition Type = "DBReady"

	// DBSyncReadyCondition Status=True condition when dbsync job completed ok
	DBSyncReadyCondition Type = "DBSyncReady"

	// ExposeServiceReadyCondition Status=True condition when service/routes to expose the service created ok
	ExposeServiceReadyCondition Type = "ExposeServiceReady"

	// BootstrapReadyCondition Status=True condition when bootstrap job completed ok
	BootstrapReadyCondition Type = "BootstrapReady"

	// DeploymentReadyCondition Status=True condition when service deployment/statefulset created ok
	DeploymentReadyCondition Type = "DeploymentReady"

	// KeystoneServiceReadyCondition This condition is mirrored from the Ready condition in the keystoneservice ref object to the service API.
	KeystoneServiceReadyCondition Type = "KeystoneServiceReady"

	// KeystoneEndpointReadyCondition This condition is mirrored from the Ready condition in the keystoneendpoint ref object to the service API.
	KeystoneEndpointReadyCondition Type = "KeystoneEndpointReady"

	// NetworkAttachmentsReadyCondition Status=True condition when all pods k8s.v1.cni.cncf.io/network-status shows configured interfaces for all the NetworkAttachments with IP address
	NetworkAttachmentsReadyCondition Type = "NetworkAttachmentsReady"

	// CronJobReadyCondition Status=True condition when cron jobs created ok.
	CronJobReadyCondition Type = "CronJobReady"

	// JobReadyCondition Status=True condition when cron jobs created ok.
	JobReadyCondition Type = "JobReady"

	// MemcachedReadyCondition - Indicates the memcached service is ready to be consumed
	MemcachedReadyCondition Type = "MemcachedReady"

	// RabbitMqTransportURLReadyCondition Status=True condition which indicates if the RabbitMQ TransportURLUrl is ready
	RabbitMqTransportURLReadyCondition Type = "RabbitMqTransportURLReady"

	// AnsibleEECondition Status=True condition when the AnsibleEE run has been created ok
	AnsibleEECondition Type = "AnsibleEEReady"

	// ServiceAccountReadyCondition Status=True condition
	ServiceAccountReadyCondition Type = "ServiceAccountReady"

	// RoleReadyCondition Status=True condition
	RoleReadyCondition Type = "RoleReady"

	// RoleBindingReadyCondition Status=True condition
	RoleBindingReadyCondition Type = "RoleBindingReady"

	// TLSInputReadyCondition Status=True condition when required TLS sources are ready
	TLSInputReadyCondition Type = "TLSInputReady"
)

Common Condition Types used by API objects.

Jump to

Keyboard shortcuts

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