Documentation
¶
Overview ¶
Inspired by https://github.com/knative/pkg/tree/97c7258e3a98b81459936bc7a29dc6a9540fa357/apis, but we chose to diverge due to the unacceptably large dependency closure of knative/pkg.
Inspired by https://github.com/knative/pkg/tree/97c7258e3a98b81459936bc7a29dc6a9540fa357/apis, but we chose to diverge due to the unacceptably large dependency closure of knative/pkg.
+k8s:deepcopy-gen=package,register +kubebuilder:object:generate=false
Index ¶
- Constants
- Variables
- func EmitDeprecatedMetrics(o *Option)
- func WitMaxConcurrentReconciles(m int) func(*Option)
- func WithFields(fields map[string]string) func(*Option)
- func WithGaugeFields(fields map[string]string) func(*Option)
- func WithGaugeLabels(labels ...string) func(*Option)
- func WithHistogramBuckets(buckets []float64) func(*Option)
- func WithLabels(labels ...string) func(*Option)
- type Condition
- type ConditionSet
- func (c ConditionSet) Clear(t string) error
- func (c ConditionSet) Get(t string) *Condition
- func (c ConditionSet) IsDependentCondition(t string) bool
- func (c ConditionSet) IsTrue(conditionTypes ...string) bool
- func (c ConditionSet) List() []Condition
- func (c ConditionSet) Root() *Condition
- func (c ConditionSet) Set(condition Condition) (modified bool)
- func (c ConditionSet) SetFalse(conditionType string, reason, message string) (modified bool)
- func (c ConditionSet) SetTrue(conditionType string) (modified bool)
- func (c ConditionSet) SetTrueWithReason(conditionType string, reason, message string) (modified bool)
- func (c ConditionSet) SetUnknown(conditionType string) (modified bool)
- func (c ConditionSet) SetUnknownWithReason(conditionType string, reason, message string) (modified bool)
- type ConditionType
- type ConditionTypes
- type Controller
- type ForOption
- type ForOptions
- type GenericObjectController
- type Object
- type Option
- type UnstructuredAdapter
- func (u *UnstructuredAdapter[T]) GetConditions() []Condition
- func (u *UnstructuredAdapter[T]) GetObjectKind() schema.ObjectKind
- func (u *UnstructuredAdapter[T]) GroupVersionKind() schema.GroupVersionKind
- func (u *UnstructuredAdapter[T]) SetConditions(conditions []Condition)
- func (u *UnstructuredAdapter[T]) SetGroupVersionKind(gvk schema.GroupVersionKind)
- func (u *UnstructuredAdapter[T]) StatusConditions(opts ...ForOption) ConditionSet
Constants ¶
const ( // ConditionReady specifies that the resource is ready. // For long-running resources. ConditionReady = "Ready" // ConditionSucceeded specifies that the resource has finished. // For resource which run to completion. ConditionSucceeded = "Succeeded" )
const ( MetricLabelNamespace = "namespace" MetricLabelName = "name" MetricLabelConditionStatus = "status" // MetricLabelToConditionStatus labels the transition_seconds histogram with // the status the condition transitioned TO. Combined with the existing // "status" label (the status being left), this lets consumers distinguish // how a dwell ended -- e.g. how long a condition was unhealthy // (status="False") before it recovered (to_status="True"). MetricLabelToConditionStatus = "to_status" )
const ( MetricSubsystem = "status_condition" TerminationSubsystem = "termination" )
Variables ¶
var ( Namespace = pmetrics.Label{ Name: MetricLabelNamespace, Help: "The namespace of the object the metric describes.", } Name = pmetrics.Label{ Name: MetricLabelName, Help: "The name of the object the metric describes.", } ConditionStatus = pmetrics.Label{ Name: MetricLabelConditionStatus, Help: "The status of a status condition (e.g. the `Ready` condition). For " + "transition metrics this is the state being left.", Values: conditionStatusValues, } ToConditionStatus = pmetrics.Label{ Name: MetricLabelToConditionStatus, Help: "The status a condition transitioned to, for transition metrics.", Values: conditionStatusValues, } )
Package-local metric dimensions specific to status-condition metrics. These are co-located with their name consts (rather than in the shared metrics package) because they are only emitted by the status controllers. The label-name consts above remain the values used in the metric label-names slices; these Label vars carry the documentation keyed by the same name.
var ConditionCount = conditionCountMetric("", pmetrics.Group, pmetrics.Kind)
Cardinality is limited to # objects * # conditions
var ConditionCurrentStatusSeconds = conditionCurrentStatusSecondsMetric("", pmetrics.Group, pmetrics.Kind)
Cardinality is limited to # objects * # conditions NOTE: This metric is based on a requeue so it won't show the current status seconds with extremely high accuracy. This metric is useful for aggregations. If you need a high accuracy metric, use operator_status_condition_last_transition_time_seconds
Cardinality is limited to # objects * # conditions * # objectives
var ConditionTransitionsTotal = conditionTransitionsTotalMetric("", pmetrics.Group, pmetrics.Kind)
Cardinality is limited to # objects * # conditions
var TerminationCurrentTimeSeconds = terminationCurrentTimeSecondsMetric("", pmetrics.Group, pmetrics.Kind)
Functions ¶
func EmitDeprecatedMetrics ¶
func EmitDeprecatedMetrics(o *Option)
func WithFields ¶
func WithGaugeFields ¶
func WithGaugeLabels ¶
func WithHistogramBuckets ¶
func WithLabels ¶
Types ¶
type Condition ¶
Condition aliases the upstream type and adds additional helper methods
func (*Condition) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition.
func (*Condition) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*Condition) GetStatus ¶
func (c *Condition) GetStatus() metav1.ConditionStatus
type ConditionSet ¶
type ConditionSet struct {
ConditionTypes
// contains filtered or unexported fields
}
ConditionSet provides methods for evaluating Conditions. +k8s:deepcopy-gen=false
func (ConditionSet) Clear ¶
func (c ConditionSet) Clear(t string) error
Clear removes the independent condition that matches the ConditionType Not implemented for dependent conditions
func (ConditionSet) Get ¶
func (c ConditionSet) Get(t string) *Condition
Get finds and returns the Condition that matches the ConditionType previously set on Conditions.
func (ConditionSet) IsDependentCondition ¶
func (c ConditionSet) IsDependentCondition(t string) bool
func (ConditionSet) IsTrue ¶
func (c ConditionSet) IsTrue(conditionTypes ...string) bool
IsTrue returns true if all condition types are true.
func (ConditionSet) List ¶
func (c ConditionSet) List() []Condition
func (ConditionSet) Root ¶
func (c ConditionSet) Root() *Condition
Root returns the root Condition, typically "Ready" or "Succeeded"
func (ConditionSet) Set ¶
func (c ConditionSet) Set(condition Condition) (modified bool)
Set sets or updates the Condition on Conditions for Condition.Type. If there is an update, Conditions are stored back sorted.
func (ConditionSet) SetFalse ¶
func (c ConditionSet) SetFalse(conditionType string, reason, message string) (modified bool)
SetFalse sets the status of conditionType and the root condition to False.
func (ConditionSet) SetTrue ¶
func (c ConditionSet) SetTrue(conditionType string) (modified bool)
SetTrue sets the status of conditionType to true with the reason, and then marks the root condition to true if all other dependents are also true.
func (ConditionSet) SetTrueWithReason ¶
func (c ConditionSet) SetTrueWithReason(conditionType string, reason, message string) (modified bool)
SetTrueWithReason sets the status of conditionType to true with the reason, and then marks the root condition to true if all other dependents are also true.
func (ConditionSet) SetUnknown ¶
func (c ConditionSet) SetUnknown(conditionType string) (modified bool)
SetUnknown sets the status of conditionType to Unknown and also sets the root condition to Unknown if no other dependent condition is in an error state.
func (ConditionSet) SetUnknownWithReason ¶
func (c ConditionSet) SetUnknownWithReason(conditionType string, reason, message string) (modified bool)
SetUnknownWithReason sets the status of conditionType to Unknown with the reason, and also sets the root condition to Unknown if no other dependent condition is in an error state.
type ConditionTypes ¶
type ConditionTypes struct {
// contains filtered or unexported fields
}
ConditionTypes is an abstract collection of the possible ConditionType values that a particular resource might expose. It also holds the "root condition" for that resource, which we define to be one of Ready or Succeeded depending on whether it is a Living or Batch process respectively.
func NewReadyConditions ¶
func NewReadyConditions(d ...string) ConditionTypes
NewReadyConditions returns a ConditionTypes to hold the conditions for the resource. ConditionReady is used as the root condition. The set of condition types provided are those of the terminal subconditions.
func NewSucceededConditions ¶
func NewSucceededConditions(d ...string) ConditionTypes
NewSucceededConditions returns a ConditionTypes to hold the conditions for the batch resource. ConditionSucceeded is used as the root condition. The set of condition types provided are those of the terminal subconditions.
func (ConditionTypes) For ¶
func (r ConditionTypes) For(object Object, opts ...ForOption) ConditionSet
For creates a ConditionSet from an object using the original ConditionTypes as a reference. Status must be a pointer to a struct.
type Controller ¶
type Controller[T Object] struct { ConditionDuration pmetrics.ObservationMetric ConditionCount pmetrics.GaugeMetric ConditionCurrentStatusSeconds pmetrics.GaugeMetric ConditionTransitionsTotal pmetrics.CounterMetric TerminationCurrentTimeSeconds pmetrics.GaugeMetric TerminationDuration pmetrics.ObservationMetric // contains filtered or unexported fields }
func NewController ¶
func NewController[T Object](client client.Client, eventRecorder record.EventRecorder, opts ...option.Function[Option]) *Controller[T]
type ForOption ¶
type ForOption func(*ForOptions)
ForOption is a functional option for For.
func WithClock ¶
WithClock sets the clock used for LastTransitionTime. Defaults to the real clock. Inject a fake clock in tests to avoid real-time dependencies.
func WithObservedOnly ¶
func WithObservedOnly() ForOption
WithObservedOnly builds the ConditionSet from the conditions already present on the object, skipping initialization of missing root/dependent conditions to Unknown. Use this when the set is a read-only reflection of observed state (e.g. metrics emission for an object the caller does not own), so absent conditions are not fabricated.
type ForOptions ¶
type ForOptions struct {
Clock clock.Clock
// ObservedOnly builds the set from conditions already present, without
// initializing absent root/dependent conditions to Unknown. See WithObservedOnly.
ObservedOnly bool
}
ForOptions configures a ConditionSet.
type GenericObjectController ¶
type GenericObjectController[T client.Object] struct { *Controller[*UnstructuredAdapter[T]] }
func NewGenericObjectController ¶
func NewGenericObjectController[T client.Object](client client.Client, eventRecorder record.EventRecorder, opts ...option.Function[Option]) *GenericObjectController[T]
type Option ¶
type Option struct {
// Current list of deprecated metrics
// - operator_status_condition_transitions_total
// - operator_status_condition_transition_seconds
// - operator_status_condition_current_status_seconds
// - operator_status_condition_count
// - operator_termination_current_time_seconds
// - operator_termination_duration_seconds
EmitDeprecatedMetrics bool
MetricLabels []string
GaugeMetricLabels []string
MetricFields map[string]string
GaugeMetricFields map[string]string
HistogramBuckets []float64
MaxConcurrentReconciles int
}
type UnstructuredAdapter ¶
type UnstructuredAdapter[T client.Object] struct { unstructured.Unstructured }
UnstructuredAdapter is an adapter for the status.Object interface. unstructuredAdapter makes the assumption that status conditions are found on status.conditions path.
func NewUnstructuredAdapter ¶
func NewUnstructuredAdapter[T client.Object](obj client.Object) *UnstructuredAdapter[T]
func (*UnstructuredAdapter[T]) GetConditions ¶
func (u *UnstructuredAdapter[T]) GetConditions() []Condition
func (*UnstructuredAdapter[T]) GetObjectKind ¶
func (u *UnstructuredAdapter[T]) GetObjectKind() schema.ObjectKind
func (*UnstructuredAdapter[T]) GroupVersionKind ¶
func (u *UnstructuredAdapter[T]) GroupVersionKind() schema.GroupVersionKind
func (*UnstructuredAdapter[T]) SetConditions ¶
func (u *UnstructuredAdapter[T]) SetConditions(conditions []Condition)
func (*UnstructuredAdapter[T]) SetGroupVersionKind ¶
func (u *UnstructuredAdapter[T]) SetGroupVersionKind(gvk schema.GroupVersionKind)
func (*UnstructuredAdapter[T]) StatusConditions ¶
func (u *UnstructuredAdapter[T]) StatusConditions(opts ...ForOption) ConditionSet