armadaerrors

package
v0.3.69-rc-8085810 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 14 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

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

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

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

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

func (err *ErrCreateResource) Error() string

type ErrInternalAuthServiceError

type ErrInternalAuthServiceError struct {
	// Optional message included with the error message.
	Message string
	// The authorization service used.
	AuthService string
	// The action/method that was trying to be performed.
	Action string
}

ErrInternalAuthServiceError is returned when an auth service encounters an internal error that is not directly related to the supplied input/ credentials.

func (*ErrInternalAuthServiceError) Error

func (err *ErrInternalAuthServiceError) Error() string

func (*ErrInternalAuthServiceError) GRPCStatus

func (err *ErrInternalAuthServiceError) GRPCStatus() *status.Status

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 ErrInvalidCredentials

type ErrInvalidCredentials struct {
	// The username half of the invalid credentials, if available.
	Username string
	// The authorization service which attempted to authenticate the user.
	AuthService string
	// Optional message included with the error message
	Message string
	// The action/method that was trying to be performed.
	Action string
}

ErrInvalidCredentials is returned when a given set of credentials cannot be authenticated by some authentication method/service.

func (*ErrInvalidCredentials) Error

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

func (*ErrInvalidCredentials) GRPCStatus

func (err *ErrInvalidCredentials) GRPCStatus() *status.Status

type ErrMaxRetriesExceeded

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

func (e *ErrMaxRetriesExceeded) Error() string

func (*ErrMaxRetriesExceeded) Unwrap

func (e *ErrMaxRetriesExceeded) Unwrap() error

type ErrMissingCredentials

type ErrMissingCredentials struct {
	// Optional message included with the error message.
	Message string
	// The authorization service used.
	AuthService string
	// The action/method that was trying to be performed.
	Action string
}

ErrMissingCredentials is returned when a given set of credentials are missing either due to omission or they cannot otherwise be decoded.

func (*ErrMissingCredentials) Error

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

func (*ErrMissingCredentials) GRPCStatus

func (err *ErrMissingCredentials) GRPCStatus() *status.Status

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

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

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

func NewCombinedErrPodUnschedulable

func NewCombinedErrPodUnschedulable(errs ...error) *ErrPodUnschedulable

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

func (*ErrPodUnschedulable) Add

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

Add updates the internal counter of errors.

func (*ErrPodUnschedulable) Error

func (err *ErrPodUnschedulable) Error() string

type ErrUnauthenticated

type ErrUnauthenticated struct {
	// The action/method that was trying to be performed.
	Action string
	// Optional message included with the error message
	Message string
}

ErrUnauthenticated represents an error that occurs when a client tries to perform some action through the gRPC API for which it cannot authenticate.

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 (*ErrUnauthenticated) Error

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

func (*ErrUnauthenticated) GRPCStatus

func (err *ErrUnauthenticated) GRPCStatus() *status.Status

type ErrUnauthorized

type ErrUnauthorized 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
}

ErrUnauthorized 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 (*ErrUnauthorized) Error

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

Jump to

Keyboard shortcuts

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