Documentation
¶
Overview ¶
Package utils provides the object management shared by the DatadogBYOCCluster and DatadogObservabilityPipelinesWorker controllers.
Index ¶
- Variables
- func ApplyControlled(ctx context.Context, c client.Client, apiReader client.Reader, ...) error
- func DeleteIfControlled(ctx context.Context, c client.Client, reader client.Reader, ...) (bool, error)
- func GetFresh(ctx context.Context, cache, apiReader client.Reader, object client.Object) error
Constants ¶
This section is empty.
Variables ¶
var ErrObjectConflict = errors.New("exists and is not controlled by")
ErrObjectConflict reports an existing object with a managed name that the owner does not control.
var HorizontalPodAutoscalerSpecChanged = predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { oldHPA, oldOK := e.ObjectOld.(*autoscalingv2.HorizontalPodAutoscaler) newHPA, newOK := e.ObjectNew.(*autoscalingv2.HorizontalPodAutoscaler) return !oldOK || !newOK || !apiequality.Semantic.DeepEqual(oldHPA.Spec, newHPA.Spec) }, }
HorizontalPodAutoscalerSpecChanged passes HorizontalPodAutoscaler updates that change the spec, filtering out status-only updates. GenerationChangedPredicate does not work here: before Kubernetes 1.37, the API server does not bump the generation of HorizontalPodAutoscalers on spec changes. Kubernetes 1.37 enables it by default through the HPAGeneration feature gate, which is GA in 1.38. Once the minimum supported Kubernetes version is 1.38, replace this predicate with GenerationChangedPredicate.
Functions ¶
func ApplyControlled ¶
func ApplyControlled(ctx context.Context, c client.Client, apiReader client.Reader, scheme *runtime.Scheme, owner, desired client.Object, fieldOwner string) error
ApplyControlled sets owner as the controller of desired and applies desired with a forced server-side apply. It returns an error wrapping ErrObjectConflict without writing when an object with the same name exists and owner does not control it. When owner controls the existing object, the apply fails if that object was replaced.
func DeleteIfControlled ¶
func DeleteIfControlled(ctx context.Context, c client.Client, reader client.Reader, owner, object client.Object, opts ...client.DeleteOption) (bool, error)
DeleteIfControlled deletes the object when it is controlled by owner and reports whether a deletion was requested. The ownership check reads the object through reader, and the deletion fails if the object changed since that read.
Types ¶
This section is empty.