mutate

package
v1.15.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retriable

func Retriable(err error) bool

Retriable identifies Kubernetes apiserver errors that are normally transient and safely retriable.

func RetriableOrConflict

func RetriableOrConflict(err error) bool

RetriableOrConflict identifies Kubernetes apiserver errors that are either retriable or a conflict (retriable with GET + mutation).

func Status

func Status(ctx context.Context, c client.Client, obj client.Object, mutate Func) (bool, error)

Status attempts to update an object's status, once.

  • If the update errors due to a UID conflict, that means the object has been deleted and re-created. So an error will be returned.
  • If the mutate.Func returns a *NoUpdateError, the update will be skipped.

func WithRetry

func WithRetry(ctx context.Context, c client.Client, obj client.Object, mutate Func) (bool, error)

WithRetry attempts to update an object until successful or update becomes unnecessary (`NoUpdateError` from the `mutate.Func`). Retries are quick, with no backoff.

  • If the update errors due to a `Retriable“ API status error, the object will be re-read from the server, re-mutated, and re-updated.
  • If the update errors due to a ResourceVersion conflict, the object will be re-read from the server, re-mutated, and re-updated.
  • If the update errors due to a UID conflict, that means the object has been deleted and re-created. So an error will be returned.
  • If the mutate.Func returns a *NoUpdateError, the update will be skipped and retries will be stopped.

Types

type Func

type Func func() error

Func is a function which mutates an existing object into its desired state.

type NoUpdateError

type NoUpdateError struct{}

NoUpdateError tells the caller that no update is required. Use with `WithRetry` and `Status` by returning a NoUpdateError from the `mutate.Func`.

func (*NoUpdateError) Error

func (nue *NoUpdateError) Error() string

Error returns the error message string

Jump to

Keyboard shortcuts

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