status

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const APIServerErrorCode = "2002"

APIServerErrorCode is the error code for a status Error originating from the kubernetes API server.

View Source
const ActionableHydrationErrorCode = "1068"

ActionableHydrationErrorCode is the error code for a user actionable Error related to the hydration process.

View Source
const EmptySourceErrorCode = "2006"

EmptySourceErrorCode is the error code for an EmptySourceError.

View Source
const EncodeDeclaredFieldErrorCode = "1067"

EncodeDeclaredFieldErrorCode is the error code for errors that happen when encoding the declared fields.

View Source
const FightErrorCode = "2005"

FightErrorCode is the error code for Config Sync fighting with other controllers.

View Source
const InsufficientPermissionErrorCode = "2013"

InsufficientPermissionErrorCode is the error code when the reconciler has insufficient permissions to manage resources.

View Source
const InternalErrorCode = "9998"

InternalErrorCode is the error code for Internal.

View Source
const InternalHydrationErrorCode = "2015"

InternalHydrationErrorCode is the error code for an internal Error related to the hydration process.

View Source
const ManagementConflictErrorCode = "1060"

ManagementConflictErrorCode is the error code for management conflict errors.

View Source
const MissingResourceErrorCode = "2011"

MissingResourceErrorCode is the error code for a MissingResourceError.

View Source
const MultipleSingletonsErrorCode = "2012"

MultipleSingletonsErrorCode is the error code for MultipleSingletonsError

View Source
const OSErrorCode = "2003"

OSErrorCode is the error code for a status Error originating from an OS-level function call.

View Source
const ObjectParseErrorCode = "1006"

ObjectParseErrorCode is the code for ObjectParseError.

View Source
const PathErrorCode = "2001"

PathErrorCode is the error code for a generic PathError.

View Source
const ResourceErrorCode = "2010"

ResourceErrorCode is the error code for a generic ResourceError.

View Source
const SourceErrorCode = "2004"

SourceErrorCode is the error code for a status Error related to the repo's source of truth.

View Source
const TransientErrorCode = "2016"

TransientErrorCode is the error code for a transient error that might be auto-resolved in the retry.

View Source
const UndocumentedErrorCode = "9999"

UndocumentedErrorCode is the error code for Undocumented.

View Source
const UnknownKindErrorCode = "1021" // Impossible to create consistent example.

UnknownKindErrorCode is the error code for UnknownObjectKindError

Variables

View Source
var EmptySourceErrorBuilder = NewErrorBuilder(EmptySourceErrorCode)

EmptySourceErrorBuilder is an ErrorBuilder for errors related to the repo's source of truth.

View Source
var InsufficientPermissionErrorBuilder = NewErrorBuilder(InsufficientPermissionErrorCode).
	Sprint("Insufficient permission. To fix, make sure the reconciler has sufficient permissions.")

InsufficientPermissionErrorBuilder represents an error related to insufficient permissions returned by the APIServer.

View Source
var InternalErrorBuilder = NewErrorBuilder(InternalErrorCode).Sprint("internal error")

InternalErrorBuilder allows creating complex internal errors.

View Source
var ManagementConflictErrorBuilder = NewErrorBuilder(ManagementConflictErrorCode)

ManagementConflictErrorBuilder is the builder for management conflict errors.

View Source
var ResourceErrorBuilder = NewErrorBuilder(ResourceErrorCode)

ResourceErrorBuilder almost always results from an API server call involving one or more resources.

SourceError is an ErrorBuilder for errors related to the repo's source of truth.

View Source
var UndocumentedErrorBuilder = NewErrorBuilder(UndocumentedErrorCode)

UndocumentedErrorBuilder builds Undocumented errors.

Functions

func CodeRegistry

func CodeRegistry() []string

CodeRegistry returns a sorted list of currently registered error codes.

func CountErrorByClass added in v1.15.1

func CountErrorByClass(errs []v1beta1.ConfigSyncError) map[string]int64

CountErrorByClass counts the errors by errorclass. The errorclass is a string derived from the error code. For example, the errorclass of a ConfigSyncErrow with the error code of "1323" is "1xxx".

func DeepEqual

func DeepEqual(left, right MultiError) bool

DeepEqual determines whether two MultiError objects are equal. DeepEqual sorts the two MultiError objects before comparing them. Two `status.Error` objects are considered equal if they have the same code and body.

func EnablePanicOnMisuse

func EnablePanicOnMisuse()

EnablePanicOnMisuse makes status.Error ensure errors are properly formatted, aren't wrapped unnecessarily, and so on. Should only be enabled in debugging and test settings, not in production.

func FormatMultiLine

func FormatMultiLine(e error) string

FormatMultiLine formats multi-errors into multi-line style Errors are joined with two new lines

func FormatSingleLine

func FormatSingleLine(e error) string

FormatSingleLine format multi-errors into single-style Each error is reformatted as single line and joined with new line

func GetSourceAnnotation

func GetSourceAnnotation(obj client.Object) string

GetSourceAnnotation returns the string value of the SourcePath Annotation. Returns empty string if unset or the object has no annotations.

func HasBlockingErrors

func HasBlockingErrors(errs MultiError) bool

HasBlockingErrors return whether `errs` include any blocking errors.

An error is blocking if it requires the users to do something so that Config Sync can sync successfully.

func HasTransientErrors added in v1.15.1

func HasTransientErrors(errs MultiError) bool

HasTransientErrors return whether `errs` include any transient errors.

A transient error is not exposed in the R*Sync API, and is expected to be auto-resolved in the next retry loop.

func NonBlockingErrors

func NonBlockingErrors(errs MultiError) []v1beta1.ConfigSyncError

NonBlockingErrors return the non-blocking errors.

func PrintResource

func PrintResource(r client.Object) string

PrintResource returns a human-readable output for the Resource.

func PurifyError

func PurifyError(e error) []string

PurifyError extracts unique errors, sort and return them as array of string

func ToCME

ToCME converts a MultiError to ConfigManagementError.

func ToCSE

ToCSE converts a MultiError to ConfigSyncErrors.

Types

type Error

type Error interface {
	MultiError
	// ToCME converts the implementor into ConfigManagementError, preserving
	// structured information.
	ToCME() v1.ConfigManagementError
	// ToCSE converts the implementor into ConfigSyncError, preserving structured
	// information.
	ToCSE() v1beta1.ConfigSyncError
	// Code is the unique identifier of the error to help users find documentation.
	Code() string
	// Body is the body of the error to be printed.
	Body() string
	// Is allows comparing error types through errors.Is.
	Is(target error) bool
	// contains filtered or unexported methods
}

Error defines a Kubernetes Nomos Vet error These are GKE Config Management directory errors which are shown to the user and documented.

func APIServerError

func APIServerError(err error, message string, resources ...client.Object) Error

APIServerError wraps an error returned by the APIServer.

func APIServerErrorf

func APIServerErrorf(err error, format string, a ...interface{}) Error

APIServerErrorf wraps an error returned by the APIServer with a formatted message.

func EmptySourceError

func EmptySourceError(current int, resourceType string) Error

EmptySourceError returns an EmptySourceError when the specified number of resources would have be deleted.

func EncodeDeclaredFieldError

func EncodeDeclaredFieldError(resource client.Object, err error) Error

EncodeDeclaredFieldError reports that an error happens when encoding the declared fields for an object.

func HydrationError

func HydrationError(code string, err error) Error

HydrationError returns a hydration error.

func InternalError

func InternalError(message string) Error

InternalError represents conditions that should ever happen, but that we check for so that we can control how the program terminates when these unexpected situations occur.

These errors specifically happen when the code has a bug - as long as objects are being used as their contracts require, and as long as they follow their contracts, it should not be possible to trigger these.

func InternalErrorf

func InternalErrorf(format string, a ...interface{}) Error

InternalErrorf returns an InternalError with a formatted message.

func InternalHydrationError

func InternalHydrationError(err error, format string, a ...interface{}) Error

InternalHydrationError returns an internal error related to the hydration process.

func InternalWrap

func InternalWrap(err error) Error

InternalWrap wraps an error as an internal error.

func MissingResourceWrap

func MissingResourceWrap(err error, msg string, resources ...client.Object) Error

MissingResourceWrap returns a MissingResourceError wrapping the given error and Resources.

func MultipleSingletonsError

func MultipleSingletonsError(duplicates ...client.Object) Error

MultipleSingletonsError reports that multiple singleton resources were found on the cluster.

func OSWrap

func OSWrap(err error) Error

OSWrap returns an Error wrapping an OS-level error.

func ObjectParseError

func ObjectParseError(resource client.Object, err error) Error

ObjectParseError reports that an object of known type did not match its definition, and so it was read in as an *unstructured.Unstructured.

func PathWrapError

func PathWrapError(err error, slashPaths ...string) Error

PathWrapError returns a PathError wrapping an error one or more relative paths.

func ResourceWrap

func ResourceWrap(err error, msg string, resources ...client.Object) Error

ResourceWrap returns a ResourceError wrapping the given error and Resources.

func TransientError added in v1.15.1

func TransientError(err error) Error

TransientError returns a transient error.

func UndocumentedError

func UndocumentedError(message string) Error

UndocumentedError returns a Undocumented with the string representation of the passed object.

func UndocumentedErrorf

func UndocumentedErrorf(format string, a ...interface{}) Error

UndocumentedErrorf returns a Undocumented with the string representation of the passed object.

func UnknownGroupKindError

func UnknownGroupKindError(gk schema.GroupKind) Error

UnknownGroupKindError reports that a GroupKind is not defined on the cluster, so we can't sync it.

func UnknownObjectKindError

func UnknownObjectKindError(resource client.Object) Error

UnknownObjectKindError reports that an object declared in the repo does not have a definition in the cluster.

type ErrorBuilder

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

ErrorBuilder constructs complex, structured error messages. Use NewErrorBuilder to register a KNV for a new code.

func NewErrorBuilder

func NewErrorBuilder(code string) ErrorBuilder

NewErrorBuilder returns an ErrorBuilder that can be used to generate errors. Registers this call with the passed unique code. Panics if there is an error code collision.

func (ErrorBuilder) Build

func (eb ErrorBuilder) Build() Error

Build returns the Error inside the ErrorBuilder.

func (ErrorBuilder) BuildWithConflictingManagers

func (eb ErrorBuilder) BuildWithConflictingManagers(resource client.Object, newManager, currentManager string) ManagementConflictError

BuildWithConflictingManagers adds the conflicting manager and the resource declared in the repository to the Error. newManager is the manager annotation for the current remediator/reconciler. currentManager is the manager annotation in the actual resource. It is also known as conflictingManager.

func (ErrorBuilder) BuildWithPaths

func (eb ErrorBuilder) BuildWithPaths(paths ...id.Path) PathError

BuildWithPaths adds paths within the repository to the Error.

func (ErrorBuilder) BuildWithResources

func (eb ErrorBuilder) BuildWithResources(resources ...client.Object) ResourceError

BuildWithResources adds resources declared in the repository to the Error.

func (ErrorBuilder) Sprint

func (eb ErrorBuilder) Sprint(message string) ErrorBuilder

Sprint adds a message string into the Error inside the ErrorBuilder.

func (ErrorBuilder) Sprintf

func (eb ErrorBuilder) Sprintf(format string, a ...interface{}) ErrorBuilder

Sprintf adds a formatted string into the Error inside the ErrorBuilder.

func (ErrorBuilder) Wrap

func (eb ErrorBuilder) Wrap(toWrap error) ErrorBuilder

Wrap adds an error into the Error inside the ErrorBuilder.

type ManagementConflictError

type ManagementConflictError interface {
	// ConflictingManager returns the annotation value of the other conflicting manager.
	ConflictingManager() string
	// CurrentManagerError returns the error that will be surfaced to the current manager.
	CurrentManagerError() ManagementConflictError
	// ConflictingManagerError returns the error that will be surfaced to the other conflicting manager.
	ConflictingManagerError() ManagementConflictError
	Error
}

ManagementConflictError indicates that the passed resource is illegally declared in multiple repositories.

func ManagementConflictErrorWrap

func ManagementConflictErrorWrap(resource client.Object, newManager string) ManagementConflictError

ManagementConflictErrorWrap returns the ManagementConflictError.

type MultiError

type MultiError interface {
	error
	Errors() []Error
}

MultiError represents a collection of errors.

func Append

func Append(m MultiError, err error, errs ...error) MultiError

Append adds one or more errors to an existing MultiError. If m, err, and errs are nil, returns nil.

Requires at least one error to be passed explicitly to prevent developer mistakes. There is no valid reason to call Append with exactly one argument.

If err is a MultiError, appends all contained errors.

type PathError

type PathError interface {
	Error
	RelativePaths() []id.Path
}

PathError defines a status error associated with one or more path-identifiable locations in the repo.

type ResourceError

type ResourceError interface {
	Error
	Resources() []client.Object
}

ResourceError defines a status error related to one or more k8s resources.

func FightError added in v1.15.1

func FightError(frequency float64, resource client.Object) ResourceError

FightError represents when the remediator is fighting over a resource object with some other process on a Kubernetes cluster.

Jump to

Keyboard shortcuts

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