Expand description
Maintaining the standard status.conditions of a resource.
These functions operate on the Condition type that Kubernetes defines for this purpose, following the same rules
as k8s.io/apimachinery/pkg/api/meta.SetStatusCondition:
- A resource has at most one condition of each
type. lastTransitionTimerecords when the condition’sstatuslast changed. It does not change when only thereason,message, orobservedGenerationdo, so it answers “how long has this beenFalse?” rather than “when was this last written?”.observedGenerationrecords themetadata.generationof the resource that the condition was determined from. A condition whoseobservedGenerationis older than the resource’s current generation describes a spec that has since been changed, so should not be trusted as describing the current one (seefind_observed).
A reconciler typically computes each condition from what it observed,
applies them with set, and writes the status back only if any of
them changed:
let change = conditions::set(
&mut status.conditions,
if ready {
DesiredCondition::new("Ready", ConditionStatus::True, "DeploymentAvailable", "")
} else {
DesiredCondition::new(
"Ready",
ConditionStatus::False,
"DeploymentUnavailable",
"waiting for the deployment's pods to become ready",
)
}
.observed_generation(generation),
);
if change.is_changed() {
// write the status
}Structs§
- Desired
Condition - A condition as a reconciler wants it to be, to be applied with
set. - Invalid
Condition Status - The error returned when parsing a string that is not
True,False, orUnknownas aConditionStatus.
Enums§
- Condition
Change - What
setchanged. - Condition
Status - The
statusof aCondition.
Functions§
- find
- Returns the condition of the given type, if present.
- find_
observed - Returns the condition of the given type, if present and determined from
the given
generationof its resource (which should be that resource’s currentmetadata.generation). - remove
- Removes the condition of the given type, returning whether it was present.
- set
- Sets the condition of
desired.type_todesired, adding it if it is not already present, and returns what changed.