...

Package runtime

import "edge-infra.dev/pkg/k8s/runtime"
Overview
Index
Subdirectories

Overview ▾

func IsImmutableError

func IsImmutableError(err error) bool

IsImmutableError checks if the given error indicates that a recoverable immutability error has been encountered, which occurs when an object failed to be applied strictly due to updating immutable fields. If there are additional causes detected (e.g., the error is caused both by an immutable field being changed and another field being invalid), the immutability error is considered non-recoverable and this function returns false. This is because the only method for recovering from an immutability error is to delete the object and re-create it -- if the next apply will not succeed due to invalid fields, the immutability error cannot be recovered from.

Error evaluation logic:

  1. Nil errors and k8s.io/apimachinery/pkg/api/errors.NewNotFound return false, because an error can't be due to immutability if doesn't already exist.
  2. k8s.io/apimachinery/pkg/api/errors.NewConflict errors return true.
  3. If the error is k8s.io/apimachinery/pkg/api/errors.NewInvalid, it is further probed for the specific cause, as immutability is just a subset of the potential invalid errors. Immutability errors should almost always indicate that the cause for the error is FieldValueForbidden, but some older buitl-in values are inconsistent and incidate the cause is FieldValueInvalid. If only FieldValueForbidden or FieldValueInvalid causes are detected, we return true.
  4. The error message is evaluated for known immutability message regexes, e.g. CEL or custom admission webhooks.

Subdirectories

Name Synopsis
..
client
conditions Package conditions implements generic functionality for working with kstatus compliant K8s resource conditions.
controller
metrics
reconcile Package reconcile implements functionality for processing reconciliation results and errors to return to controller-runtime.
recerr Package recerr implements custom controller reconciliation error types and utilities used during reconciliaton result summarization.
events Package events provides a Recorder to record Kubernetes Events.
inventory Package inventory provides functionality for working with resource inventories being managed by K8s controllers or other actors.
objectrestarter Package objectrestarter provides a utility for restarting workloads using the kubectl annotation used by K8s for graceful restarting.
patch
sap Package sap implements a server-side apply (SSA) resource manager for K8s.
install Package install implements naive one-shot application of K8s objects using server-side apply.
statusreaders