armadaerrors

package
v0.3.28 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package armadaerrors contains generic errors that should be returned by code handling gRPC requests. gRPC interceptors will look for the error types defined in this file and automatically set the gRPC status and return code correctly.

If multiple errors occur in some function (e.g., if multiple queues already exists), that function should return an error of type multierror.Error from package github.com/hashicorp/go-multierror that encapsulates those individual errors.

Index

Constants

This section is empty.

Variables

View Source
var NATS_CONNECTION_ERRORS = []error{
	nats.ErrConnectionClosed,
	nats.ErrConnectionDraining,
	nats.ErrDrainTimeout,
	nats.ErrConnectionReconnecting,
	nats.ErrTimeout,
	nats.ErrBadTimeout,
	nats.ErrNoServers,
	nats.ErrDisconnected,
}

Functions

func CodeFromError

func CodeFromError(err error) codes.Code

CodeFromError maps error types to gRPC return codes. Uses errors.As to look through the chain of errors, as opposed to just considering the topmost error in the chain.

func IsNetworkError added in v0.3.0

func IsNetworkError(err error) bool

IsNetworkError returns true if err is a network-related error. If err is an error chain, this function returns true if any error in the chain is a network error.

For details, see https://stackoverflow.com/questions/22761562/portable-way-to-detect-different-kinds-of-network-error

func IsRetryablePostgresError added in v0.3.0

func IsRetryablePostgresError(err error) bool

func StreamServerInterceptor

func StreamServerInterceptor(maxErrorSize uint) grpc.StreamServerInterceptor

StreamServerInterceptor returns an interceptor that extracts the cause of an error chain and returns it as a gRPC status error. It also limits the number of characters returned.

func UnaryServerInterceptor

func UnaryServerInterceptor(maxErrorSize uint) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns an interceptor that extracts the cause of an error chain and returns it as a gRPC status error. It also limits the number of characters returned.

To log the full error chain and return only the cause to the user, insert this interceptor before the logging interceptor.

Types

type ErrAlreadyExists

type ErrAlreadyExists struct {
	Type    string // Resource type, e.g., "queue" or "user"
	Value   string // Resource name, e.g., "Bob"
	Message string // An optional message to include in the error message
}

ErrAlreadyExists is a generic error to be returned whenever some resource already exists. Type and Message are optional and are omitted from the error message if not provided.

func (*ErrAlreadyExists) Error

func (err *ErrAlreadyExists) Error() (s string)

type ErrCreateResource added in v0.3.15

type ErrCreateResource struct {
	// Resource attempting to create, e.g., pod or service.
	Type string
	// Resource name.
	Name string
	// Optional error message.
	Message string
}

ErrCreateResource indicates that some Kubernetes resource could not be created. It's used in the executor.

func (*ErrCreateResource) Error added in v0.3.15

func (err *ErrCreateResource) Error() string

type ErrInvalidArgument

type ErrInvalidArgument struct {
	Name    string      // Name of the field referred to, e.g., "priorityFactor"
	Value   interface{} // The invalid value that was provided
	Message string      // An optional message to include with the error message, e.g., explaining why the value is invalid
}

ErrInvalidArgument is a generic error to be returned on invalid argument. Message is optional and is omitted from the error message if not provided.

func (*ErrInvalidArgument) Error

func (err *ErrInvalidArgument) Error() string

type ErrMaxRetriesExceeded added in v0.3.0

type ErrMaxRetriesExceeded struct {
	Message   string
	LastError error
}

ErrMaxRetriesExceeded is an error that indicates we have retried an operation so many times that we have given up The internal error should contain the last error before giving up

func (*ErrMaxRetriesExceeded) Error added in v0.3.0

func (e *ErrMaxRetriesExceeded) Error() string

func (*ErrMaxRetriesExceeded) Unwrap added in v0.3.0

func (e *ErrMaxRetriesExceeded) Unwrap() error

type ErrNoPermission added in v0.3.0

type ErrNoPermission struct {
	// Principal that attempted the action
	Principal string
	// The missing permission
	Permission string
	// The attempted action
	Action string
	// Optional message included with the error message
	Message string
}

ErrNoPermission represents an error that occurs when a client tries to perform some action through the gRPC API for which it does not have permissions.

It may be necessary populate the Action field by recovering this error at the gRPC endpoint (using errors.As) and updating the field in-place.

func (*ErrNoPermission) Error added in v0.3.0

func (err *ErrNoPermission) Error() (s string)

type ErrNotFound

type ErrNotFound struct {
	Type    string
	Value   string
	Message string
}

ErrNotFound is a generic error to be returned whenever some resource isn't found. Type and Message are optional and are omitted from the error message if not provided.

See ErrAlreadyExists for more info.

func (*ErrNotFound) Error

func (err *ErrNotFound) Error() (s string)

type ErrPodUnschedulable added in v0.3.8

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

ErrPodUnschedulable indicates that a pod can't be scheduled on any node type.

func NewCombinedErrPodUnschedulable added in v0.3.8

func NewCombinedErrPodUnschedulable(errs ...error) *ErrPodUnschedulable

NewCombinedErrPodUnschedulable returns a new ErrPodUnschedulable with countFromReasons aggregated over all arguments.

func (*ErrPodUnschedulable) Add added in v0.3.8

func (err *ErrPodUnschedulable) Add(reason string, count int) *ErrPodUnschedulable

Add updates the internal counter of errors.

func (*ErrPodUnschedulable) Error added in v0.3.8

func (err *ErrPodUnschedulable) Error() string

Jump to

Keyboard shortcuts

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