idler

package
v0.0.0-...-c57ad4d Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedKind = errors.New("unsupported idle owner kind")

ErrUnsupportedKind is returned by IdleOwner when the owner kind is not in the idle matrix, or when the kind requires deletion and SkipDeleteKinds is true.

View Source
var SupportedScaleResources = map[schema.GroupVersionKind]schema.GroupVersionResource{
	schema.GroupVersion{Group: "camel.apache.org", Version: "v1"}.WithKind("Integration"):          schema.GroupVersion{Group: "camel.apache.org", Version: "v1"}.WithResource("integrations"),
	schema.GroupVersion{Group: "camel.apache.org", Version: "v1alpha1"}.WithKind("KameletBinding"): schema.GroupVersion{Group: "camel.apache.org", Version: "v1alpha1"}.WithResource("kameletbindings"),
}

SupportedScaleResources maps Camel kinds that must be idled via the scale subresource (rather than a direct dynamic client patch of spec.replicas).

Functions

func LogOwnershipChain

func LogOwnershipChain(logger logr.Logger, ownerChain []*owners.ObjectWithGVR, pod *corev1.Pod)

LogOwnershipChain logs the controller ownership chain for the given pod.

Types

type Idler

type Idler struct {
	// contains filtered or unexported fields
}

Idler applies owner-idle actions (scale/stop/patch/delete) for known workload kinds.

func New

func New(discoveryClient discovery.ServerResourcesInterface, dynamicClient dynamic.Interface, scalesClient scale.ScalesGetter, restClient rest.Interface) *Idler

New creates an Idler with the clients required for the full owner-idle kind matrix.

func (*Idler) IdleFromPod

func (i *Idler) IdleFromPod(ctx context.Context, pod *corev1.Pod, opts Options) (Result, error)

IdleFromPod walks the pod's owner chain and idles up to two known owners. It never creates Notifications and never deletes the Pod; see Result.PodDeleteRecommended.

func (*Idler) IdleOwner

func (i *Idler) IdleOwner(ctx context.Context, ownerWithGVR *owners.ObjectWithGVR, opts Options) error

IdleOwner applies the kind-specific idle action for a single known owner. Unknown kinds (and delete-kinds when SkipDeleteKinds is true) return ErrUnsupportedKind so callers can skip them.

func (*Idler) OwnerFetcher

func (i *Idler) OwnerFetcher() *owners.OwnerFetcher

OwnerFetcher returns the OwnerFetcher used to walk controller owner chains.

type Options

type Options struct {
	// TimeoutSeconds is the ServingRuntime InferenceService age cutoff.
	// InferenceServices older than now-TimeoutSeconds are deleted.
	// 0 means delete nothing.
	TimeoutSeconds int32

	// SkipDeleteKinds skips idling via delete for DaemonSet, Job, DataVolume,
	// PersistentVolumeClaim, and ServingRuntime (treated as unsupported).
	// The zero value (false) keeps the full matrix, including deletes.
	// On-demand callers should set this to true to skip deletes for the safer default.
	SkipDeleteKinds bool

	// SecondOwnerPolicy controls when a second known owner is idled.
	// The zero value is SecondOwnerAlways.
	SecondOwnerPolicy SecondOwnerPolicy

	// PodTimeoutSeconds is used with SecondOwnerAfterTimeout for the 105%/110% gates.
	// Ignored when SecondOwnerPolicy is SecondOwnerAlways.
	PodTimeoutSeconds int32
}

Options configures idle actions and IdleFromPod owner-walk policy.

type Result

type Result struct {
	Kind string
	Name string
	// PodDeleteRecommended is true when no known owner remains as the idle target
	// (standalone/unknown chain, or SecondOwnerAfterTimeout 110% stuck case).
	PodDeleteRecommended bool
}

Result is the outcome of IdleFromPod. Common never deletes the Pod; callers that allow last-resort pod deletion should act when PodDeleteRecommended is true.

type SecondOwnerPolicy

type SecondOwnerPolicy int

SecondOwnerPolicy controls when IdleFromPod idles a second known owner.

const (
	// SecondOwnerAlways tries up to two known owners (on-demand).
	SecondOwnerAlways SecondOwnerPolicy = iota
	// SecondOwnerAfterTimeout tries the second owner only when the first fails or the pod
	// has been running longer than 105% of PodTimeoutSeconds. When nothing remains
	// attempted and the pod exceeds 110%, Kind/Name are cleared and PodDeleteRecommended
	// is set so the caller may delete the pod.
	SecondOwnerAfterTimeout
)

Jump to

Keyboard shortcuts

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