ateerrors

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const MetadataKeyActorCrashed = "actorCrashed"

MetadataKeyActorCrashed marks (in ErrorInfo.Metadata) a failure that requires the control plane to crash the actor.

Variables

AllReasons contains all valid Reason constants for validation. Keep in sync with const block above.

Functions

func ActorCrashRequested

func ActorCrashRequested(err error) bool

ActorCrashRequested reports whether any ErrorInfo carried by err has the actorCrashed=true directive, i.e. the failure requires the control plane to crash the actor.

func ActorCrashedMetadata

func ActorCrashedMetadata() map[string]string

ActorCrashedMetadata returns the AIP-193 metadata marking a failure as requiring the actor to be crashed. The control plane reads it via ActorCrashRequested.

func CrashIfReason

func CrashIfReason(ctx context.Context, err error, reasons ...Reason) error

CrashIfReason sets the err to a DataLoss gRPC status with the actor-crash directive iff its chain carries one of the given Reasons; any other error is returned unchanged. Claiming is per call site: the same tagged failure may crash the actor in one RPC and stay retriable in another.

func ExtractReason

func ExtractReason(err error) string

ExtractReason returns the validated enum reason string from an error's AIP-193 ErrorInfo detail or wrapped ateerrors.Reason, or empty string if unclassified.

func IsValidReason

func IsValidReason(s string) bool

IsValidReason reports whether a string matches a known ateerrors.Reason enum.

func NewGRPCError

func NewGRPCError(ctx context.Context, grpcCode codes.Code, reason Reason, metadata map[string]string, err error) error

NewGRPCError builds an internal gRPC status error per AIP-193 (https://google.aip.dev/193#status-message), with a google.rpc.ErrorInfo detail carrying the given Reason ("UNSET" when empty). metadata carries additional structured directives such as ActorCrashedMetadata(), which the control plane reads via ActorCrashRequested to decide whether to crash the actor.

Types

type Reason

type Reason string

Reason is the AIP-193 ErrorInfo.Reason: a bounded, UPPER_SNAKE_CASE enum of failure causes the control plane can classify on. A Reason is also an error: source layers tag failures with fmt.Errorf("%w: ...", ReasonX, err), and each RPC boundary claims the Reasons it treats as terminal (CrashIfReason); untagged errors stay retriable.

const (
	ReasonTerminalFileSystemError Reason = "TERMINAL_FILE_SYSTEM_ERROR"
	ReasonInvalidSandboxAsset     Reason = "INVALID_SANDBOX_ASSET"
	ReasonInvalidCheckpointResult Reason = "INVALID_CHECKPOINT_RESULT"
	ReasonFaileSaveSnapshot       Reason = "FAILED_SAVE_SNAPSHOT"
	ReasonInvalidObjectURL        Reason = "INVALID_OBJECT_URL"
	ReasonFailedGetExternalObject Reason = "FAILED_GET_EXTERNAL_OBJECT"
	// ReasonInvalidContainerConfig marks a container whose configuration cannot
	// produce a runnable process (e.g. the resolved argv is empty because the
	// image defines no ENTRYPOINT/CMD and the ActorTemplate sets no command/args).
	ReasonInvalidContainerConfig Reason = "INVALID_CONTAINER_CONFIG"

	// ReasonLocalSnapshotGone marks a paused actor whose local snapshot is
	// missing from the node it was recorded on and absent from object storage:
	// its state is unrecoverable.
	ReasonLocalSnapshotGone Reason = "LOCAL_SNAPSHOT_GONE"

	// ReasonWorkloadNotReady marks a container that started but never passed its
	// readyz probe before the probe's deadline. First reason in the workload
	// fault domain (ateattr.FailureDomain); the operation it failed under is
	// ate.actor.operation.name, not part of this value.
	//
	// Confounded by a slow node: a cold image or a throttled CPU also runs the
	// probe out of time. ate.actor.restore.duration.* on the same record
	// separates the two.
	ReasonWorkloadNotReady Reason = "WORKLOAD_NOT_READY"

	// Control-plane failure reasons for ate.actor.crashes metric.
	ReasonCorruptedAssignment Reason = "CORRUPTED_ASSIGNMENT"
	ReasonWorkerReassigned    Reason = "WORKER_REASSIGNED"
	ReasonWorkerPodGone       Reason = "WORKER_POD_GONE"
	ReasonUnknown             Reason = "UNKNOWN"
)

NOTE: When adding a Reason constant below, also add it to AllReasons.

func (Reason) Error

func (r Reason) Error() string

Error makes a Reason wrappable with %w and matchable with errors.Is/As.

Jump to

Keyboard shortcuts

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