allocatorapi

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// PlanPendingMessage is used to discard
	PlanPendingMessage = "There is a plan still pending, cancel that or wait for it to complete before restarting"
)
View Source
const (
	// UnhealthyQuery is used to obtain the list of unhealthy allocators.
	UnhealthyQuery = "status.connected:false AND _exists_:instances"
)

Variables

This section is empty.

Functions

func CheckVacateFailures

func CheckVacateFailures(failures *models.MoveClustersDetails, filter []string, allocatorID string) error

CheckVacateFailures iterates over the list of failures returning a multierror of VacateError if any of failures are found.

nolint because of the complexity score here

func ComputeVacateRequest

func ComputeVacateRequest(pr *models.MoveClustersDetails, resources, to []string, overrides PlanOverrides) *models.MoveClustersRequest

ComputeVacateRequest filters the tentative resources that would be moved and filters those by ID if it's specified, also setting any preferred allocators if that is sent. Any resource plan overrides will be set in this function. nolint due to complexity

func DeleteAllocatorMetadataItem

func DeleteAllocatorMetadataItem(params MetadataDeleteParams) error

DeleteAllocatorMetadataItem delete a single metadata item to a given allocators metadata

func FilterByTag

func FilterByTag(tags map[string]string, allocators []*models.AllocatorInfo) []*models.AllocatorInfo

FilterByTag filters a list of allocators based on metadata tags and returns a new matched list

func FilterConnectedOrWithInstances

func FilterConnectedOrWithInstances(allocators []*models.AllocatorInfo) []*models.AllocatorInfo

FilterConnectedOrWithInstances filters a list of allocators and returns only the connected ones or those who have more than one instance

func Get

func Get(params GetParams) (*models.AllocatorInfo, error)

Get obtains an allocator from an ID

func GetAllocatorMetadata

func GetAllocatorMetadata(params MetadataGetParams) ([]*models.MetadataItem, error)

GetAllocatorMetadata Retrieves the metadata for a given allocator

func List

func List(params ListParams) (*models.AllocatorOverview, error)

List obtains the full list of allocators

func Search(params SearchParams) (*models.AllocatorOverview, error)

Search searches all the allocators using Query DSL

func SetAllocatorMetadataItem

func SetAllocatorMetadataItem(params MetadataSetParams) error

SetAllocatorMetadataItem sets a single metadata item to a given allocators metadata

func StartMaintenance

func StartMaintenance(params MaintenanceParams) error

StartMaintenance sets an allocator to maintenance mode

func StopMaintenance

func StopMaintenance(params MaintenanceParams) error

StopMaintenance unsets an allocator to maintenance mode

func Vacate

func Vacate(params *VacateParams) error

Vacate drains allocated resource instances away from the allocator list either to a specific allocator list or we let the constructor decide if that is empty. If resources is set, it will only move the instances that are part of those IDs. If kind is specified, it will only move the resources that match that kind. If none is specified it will add all of the resources in the allocator. The maximum concurrent moves is controlled by the Concurrency parameter.

func VacateCluster

func VacateCluster(params *VacateClusterParams) error

VacateCluster moves a resource node off an allocator.

func VacateClusterInPool

func VacateClusterInPool(p pool.Validator) error

VacateClusterInPool vacates a resource from an allocator, complying with the pool.RunFunc signature.

Types

type GetParams

type GetParams struct {
	*api.API
	ID     string
	Region string
}

GetParams is used to get an allocator

func (GetParams) Validate

func (params GetParams) Validate() error

Validate ensures that the parameters are correct

type ListParams

type ListParams struct {
	// Required API instance.
	*api.API

	// Required region on which to perform the allocator list.
	Region string

	// Optional Elasticsearch search query.
	Query string

	// Optional filter tags with expected format: key:value slice. i.e.
	// [key:val, key:value].
	FilterTags string

	// Optional toggle to show all allocators (By default connected:false) are
	// omitted.
	ShowAll bool

	// Optional number of allocators to return (Defaults to 100).
	Size int64
}

ListParams is used to list allocators

func (ListParams) Validate

func (params ListParams) Validate() error

Validate ensures that the parameters are correct

type MaintenanceParams

type MaintenanceParams struct {
	*api.API
	ID     string
	Region string
}

MaintenanceParams is used to set / unset maintenance mode

func (MaintenanceParams) Validate

func (params MaintenanceParams) Validate() error

Validate ensures that the parameters are correct

type MetadataDeleteParams

type MetadataDeleteParams struct {
	*api.API
	ID, Key string
	Region  string
}

MetadataDeleteParams is used to delete a single metadata key

func (MetadataDeleteParams) Validate

func (params MetadataDeleteParams) Validate() error

Validate ensures that the parameters are correct

type MetadataGetParams

type MetadataGetParams struct {
	*api.API
	ID     string
	Region string
}

MetadataGetParams is used to retrieve allocator metadata

func (MetadataGetParams) Validate

func (params MetadataGetParams) Validate() error

Validate ensures that the parameters are correct

type MetadataSetParams

type MetadataSetParams struct {
	*api.API
	ID, Key, Value string
	Region         string
}

MetadataSetParams is is used to set a single allocator metadata key

func (MetadataSetParams) Validate

func (params MetadataSetParams) Validate() error

Validate ensures that the parameters are correct

type PlanOverrides

type PlanOverrides struct {
	// SkipSnapshot overwrites the Transient part of an Elastisearch vacate.
	SkipSnapshot      *bool
	SkipDataMigration *bool
	OverrideFailsafe  *bool
}

PlanOverrides is used to override any API value that is returned by default with the specified value.

type SearchParams

type SearchParams struct {
	Request models.SearchRequest
	*api.API
	Region string
}

SearchParams contains parameters used to search allocator's data using Query DSL

func (SearchParams) Validate

func (params SearchParams) Validate() error

Validate validates SearchParams

type VacateClusterParams

type VacateClusterParams struct {
	PreferredAllocators []string
	ClusterFilter       []string
	// Plan body overrides to place in all of the vacate clusters.
	PlanOverrides
	Region    string
	ID        string // allocatorID
	ClusterID string
	Kind      string
	*api.API
	TrackFrequency time.Duration
	AllocatorDown  *bool
	MoveOnly       *bool
	Output         *output.Device
	OutputFormat   string
	MaxPollRetries uint8
	SkipTracking   bool
}

VacateClusterParams is used by VacateCluster to move a cluster node from an allocator.

func (VacateClusterParams) Validate

func (params VacateClusterParams) Validate() error

Validate validates the parameters

type VacateError added in v1.1.0

type VacateError struct {
	AllocatorID string `json:"allocator_id,omitempty"`
	ResourceID  string `json:"resource_id,omitempty"`
	Kind        string `json:"kind,omitempty"`
	Ctx         string `json:"context,omitempty"`
	Err         error  `json:"error,omitempty"`
}

VacateError wraps an error and enriches it with some fields to be able to have a consistent output (resourcePrefixErrFmt). Or by being serialized to JSON by using `multierror.WithFormat`.

func (VacateError) Error added in v1.1.0

func (e VacateError) Error() string

func (VacateError) MarshalJSON added in v1.1.0

func (e VacateError) MarshalJSON() ([]byte, error)

MarshalJSON Implements the json.Marshaler interface to be able to modify the error and format it in JSON.w

type VacateParams

type VacateParams struct {
	*api.API

	Region string

	// List of allocators that will be marked to be vacated.
	Allocators []string

	// List of allocators to be used as potential targets.
	PreferredAllocators []string

	// Can specify a list of cluster IDs that will be moved
	// of N numbers of allocators.
	ClusterFilter []string

	// If specified it will only move clusters that match the kind
	// (elasticsearch, kibana).
	KindFilter string

	// Maximum number of concurrent cluster moves at any time.
	Concurrency uint16

	// Output device where the progress will be sent.
	Output *output.Device

	// OutputFormat to use
	OutputFormat string

	// Maximum number of errors to allow the plan status poller to tolerate.
	MaxPollRetries uint8

	// Poll frequency
	TrackFrequency time.Duration

	// Optional value to be set to the pool on construction.
	PoolTimeout pool.Timeout

	// Optional value to be set to override the default autodiscovery of an
	// allocator's health. This can only be used when a single allocator is
	// specified.
	AllocatorDown *bool

	// Optional value to be set to keep the cluster in its current -possibly broken- state and just does the
	// bare minimum to move the requested instances across to another allocator.
	MoveOnly *bool

	// SkipTracking skips displaying and waiting for the individual vacates to complete.
	// Setting it to true will render the concurrency flag pretty much ineffective since
	// the vacate action is asynchronous and the only thing keeping the working items in
	// the pool is the tracking function call which synchronously waits until the vacate
	// has effectively finished.
	SkipTracking bool

	// Plan body overrides to place in all of the vacate clusters.
	PlanOverrides
}

VacateParams used to vacate N allocators or clusters. nolint

func (VacateParams) Validate

func (params VacateParams) Validate() error

Validate validates the parameters

Jump to

Keyboard shortcuts

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