utils

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 10 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

Index

Constants

This section is empty.

Variables

View Source
var (
	LifecycleEnabledPredicate = predicate.NewPredicateFuncs(func(object client.Object) bool {
		if hv, ok := object.(*kvmv1.Hypervisor); ok {
			return hv.Spec.LifecycleEnabled
		}
		return true
	})
)
View Source
var StatusPatchBackoff = wait.Backoff{
	Steps:    10,
	Duration: 50 * time.Millisecond,
	Factor:   2.0,
	Jitter:   0.2,
}

StatusPatchBackoff is a retry backoff for status patches that may conflict with other controllers. Uses exponential backoff with more retries than the default to handle high contention scenarios.

Functions

func ConditionFromStatus added in v1.3.0

ConditionFromStatus converts a single metav1.Condition into a *k8sacmetav1.ConditionApplyConfiguration, preserving all fields verbatim (including LastTransitionTime and ObservedGeneration).

Controllers must seed their apply-config payload with the conditions they own before mutating them. With +listType=map / +listMapKey=type on the CRD, SSA merges conditions by the "type" key: conditions owned by other field managers are left untouched, and conditions previously written by this field manager that are absent from the payload are pruned. Therefore each controller should include all conditions it has previously set — and only those — in every Apply call.

func Difference added in v1.2.1

func Difference[S ~[]E, E comparable](s1, s2 S) S

Difference returns all elements in s2 that are not in s1.

func PatchHypervisorStatusWithRetry added in v1.1.0

func PatchHypervisorStatusWithRetry(ctx context.Context, c k8sclient.Client, name, fieldOwner string, updateFn func(*kvmv1.Hypervisor)) error

PatchHypervisorStatusWithRetry patches hypervisor status with retry on conflict. The updateFn receives a fresh copy of the hypervisor and should apply status changes to it. It re-fetches the resource before each retry attempt to get the latest resourceVersion.

func SetApplyConfigurationStatusCondition added in v1.3.0

func SetApplyConfigurationStatusCondition(conditions *[]k8sacmetav1.ConditionApplyConfiguration, newCondition k8sacmetav1.ConditionApplyConfiguration)

SetApplyConfigurationStatusCondition sets the corresponding condition in conditions to newCondition. It mirrors the behaviour of k8s.io/apimachinery/pkg/api/meta.SetStatusCondition:

  1. If a condition of the specified type does not exist, newCondition is appended. LastTransitionTime is set to now if not provided.
  2. If a condition of the specified type already exists, all fields are updated. LastTransitionTime is updated to now (or the provided value) only when Status changes; otherwise the existing LastTransitionTime is preserved.

Types

This section is empty.

Jump to

Keyboard shortcuts

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