resourceversion

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareResourceVersion

func CompareResourceVersion(a, b string) (int, error)

CompareResourceVersion compares two ResourceVersions for objects of the same resource. Returns -1 if a < b, 0 if a == b, +1 if a > b.

Compares as integers, not lexically (e.g. "9" < "10"). Mirrors k8s.io/apimachinery/pkg/util/resourceversion once we upgrade past v0.34. TODO: Remove this once we upgrade past v0.34.

Types

type InvalidResourceVersion

type InvalidResourceVersion struct {
	RV string
}

InvalidResourceVersion is returned when a resource version is not a well-formed positive integer.

func (InvalidResourceVersion) Error

func (i InvalidResourceVersion) Error() string

type Tracker

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

Tracker remembers the ResourceVersion of the last successful write this controller made for each object key, so sync can short-circuit (with a brief requeue) when the informer cache hasn't yet observed our previous write.

Without this guard, a reconcile enqueued while a prior write is still propagating to the informer can read pre-write state and act on stale inputs — or, worse, overwrite the informer cache directly (the writeBackToInformer anti-pattern).

TODO: if Argo Rollouts moves to controller-runtime, replace this with the cached client's ReadYourOwnWrites option once kubernetes-sigs/controller-runtime#3473 lands.

func NewTracker

func NewTracker() *Tracker

NewTracker returns an empty tracker ready for use.

func (*Tracker) Forget

func (t *Tracker) Forget(key string)

Forget drops any record for key. Call when an object has been deleted.

func (*Tracker) IsCacheStale

func (t *Tracker) IsCacheStale(key, cachedRV string) bool

IsCacheStale reports whether cachedRV is strictly older than the last ResourceVersion we wrote for key. Returns false when we have no record, when the cache is at or ahead of our last write, or when either ResourceVersion is malformed (fail open).

func (*Tracker) Record

func (t *Tracker) Record(key, rv string)

Record stores rv as the most recent ResourceVersion we wrote for key. No-op for empty rv.

Jump to

Keyboard shortcuts

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