statuspatching

package
v0.1.79 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package statuspatching provides helpers for safely mutating Kubernetes status subresources using optimistic locking.

Multiple HyperShift controllers (CPO, HCCO, HO, karpenter-operator) write to shared status objects such as HostedControlPlane. Without optimistic locking, concurrent writers silently overwrite each other's changes. These helpers enforce the correct pattern: deep-copy before mutation, skip no-op updates, and always use MergeFromWithOptimisticLock so that stale writes return a conflict error instead of succeeding silently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PatchStatus

func PatchStatus(ctx context.Context, c client.Client, obj client.Object, mutate func() error) error

PatchStatus re-fetches the object, applies mutate, and patches with MergeFromWithOptimisticLock. On conflict the whole cycle is retried automatically, so callers never need to handle 409s themselves. mutate must only modify status fields on obj.

func PatchStatusCondition

func PatchStatusCondition(ctx context.Context, c client.Client, obj client.Object, conditions *[]metav1.Condition, condition metav1.Condition) error

PatchStatusCondition sets a single condition using optimistic-lock patching. It uses SetStatusCondition's own change detection to skip no-ops reliably, avoiding false positives from LastTransitionTime being stamped with time.Now(). Pass a pointer to the object's conditions slice (e.g. &hcp.Status.Conditions) since HCP types expose conditions as a bare field, not via getter/setter methods.

Types

This section is empty.

Jump to

Keyboard shortcuts

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