plugins

package
v0.0.0-...-83e7cae Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServerDeletionTimeout is how long the "server-groups" asset manager will
	// wait for servers to be deleted before reporting an error.
	ServerDeletionTimeout = 3 * time.Minute
	// ServerCreationTimeout is how long the "server-groups" asset manager will
	// wait for new servers to go into state ACTIVE before reporting an error.
	ServerCreationTimeout = 5 * time.Minute
	// ServerPollInterval is how often servers are polled during state transitions
	// when the desired state has not been reached yet.
	ServerPollInterval = 10 * time.Second
)

Variables

This section is empty.

Functions

func Classify

func Classify(err error) (castellum.OperationOutcome, error)

Classify inspects the given error, unwraps UserError if possible, and adds an appropriate castellum.OperationOutcome to the result.

Types

type AssetManagerStatic

type AssetManagerStatic struct {
	AssetType                 db.AssetType
	Assets                    map[string]map[string]StaticAsset
	UsageMetrics              []castellum.UsageMetric
	CheckResourceAllowedFails bool
	SetAssetSizeFails         bool
	ExpectsConfiguration      bool
	ConflictsWithAssetType    db.AssetType
}

AssetManagerStatic is a core.AssetManager for testing purposes. It just contains a static list of assets for a single asset type. No requests against OpenStack are ever made by it.

Attempts to resize assets will succeed if and only if `newSize > usage`.

func (AssetManagerStatic) CheckResourceAllowed

func (m AssetManagerStatic) CheckResourceAllowed(assetType db.AssetType, scopeUUID, configJSON string, existingResources map[db.AssetType]struct{}) error

CheckResourceAllowed implements the core.AssetManager interface.

func (AssetManagerStatic) GetAssetStatus

func (m AssetManagerStatic) GetAssetStatus(_ context.Context, res db.Resource, assetUUID string, previousStatus *core.AssetStatus) (core.AssetStatus, error)

GetAssetStatus implements the core.AssetManager interface.

func (AssetManagerStatic) InfoForAssetType

func (m AssetManagerStatic) InfoForAssetType(assetType db.AssetType) *core.AssetTypeInfo

InfoForAssetType implements the core.AssetManager interface.

func (AssetManagerStatic) Init

func (m AssetManagerStatic) Init(provider core.ProviderClient) (err error)

Init implements the core.AssetManager interface.

func (AssetManagerStatic) ListAssets

func (m AssetManagerStatic) ListAssets(_ context.Context, res db.Resource) ([]string, error)

ListAssets implements the core.AssetManager interface.

func (AssetManagerStatic) PluginTypeID

func (m AssetManagerStatic) PluginTypeID() string

PluginTypeID implements the core.AssetManager interface.

func (AssetManagerStatic) SetAssetSize

func (m AssetManagerStatic) SetAssetSize(res db.Resource, assetUUID string, oldSize, newSize uint64) (castellum.OperationOutcome, error)

SetAssetSize implements the core.AssetManager interface.

type StaticAsset

type StaticAsset struct {
	Size              uint64
	Usage             uint64
	StrictMinimumSize *uint64
	StrictMaximumSize *uint64

	// When non-zero, these fields model a resize operation that will only be
	// reflected after GetAssetStatus() has been called for as many times as
	// indicated in the .RemainingDelay field.
	NewSize        uint64
	RemainingDelay uint

	// When true, return a bogus error from GetAssetStatus().
	CannotGetAssetStatus bool

	// When true, return a core.AssetNotFoundError from GetAssetStatus().
	CannotFindAsset bool
}

StaticAsset represents an asset managed by AssetManagerStatic. It is only used in tests as a double for an actual asset.

type UserError

type UserError struct {
	Inner error
}

UserError is an error wrapper that allows to mark errors as "failed" instead of "errored" without having to carry a separate OperationOutcome value.

TODO upstream this into internal/core and remove OperationOutcome return values from the fallible methods on AssetManager

func (UserError) Cause

func (e UserError) Cause() error

Cause implements the causer interface implied by errors.Cause().

func (UserError) Error

func (e UserError) Error() string

Error implements the builtin/error interface.

Jump to

Keyboard shortcuts

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