utils

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package utils provides the object management shared by the DatadogBYOCCluster and DatadogObservabilityPipelinesWorker controllers.

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

func GetFresh

func GetFresh(ctx context.Context, cache, apiReader client.Reader, object client.Object) error

GetFresh reads the object from the cache, and from the API server when the cache does not have it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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