allocwatcher

package
v1.6.109 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package allocwatcher allows blocking until another allocation - whether running locally or remotely - completes and migrates the allocation directory if necessary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAllocWatcher

NewAllocWatcher creates a PrevAllocWatcher if either PreviousAllocation or PreemptedRunners are set. If any of the allocs to watch have local runners, wait for them to terminate directly. For allocs which are either running on another node or have already terminated their alloc runners, use a remote backend which watches the alloc status via rpc.

func NewGroupAllocWatcher

func NewGroupAllocWatcher(watchers ...config.PrevAllocWatcher) config.PrevAllocWatcher

Types

type AllocRunnerMeta

type AllocRunnerMeta interface {
	GetAllocDir() *allocdir.AllocDir
	Listener() *cstructs.AllocListener
	Alloc() *structs.Allocation
}

AllocRunnerMeta provides metadata about an AllocRunner such as its alloc and alloc dir.

type Config

type Config struct {
	// Alloc is the current allocation which may need to block on its
	// previous allocation stopping.
	Alloc *structs.Allocation

	// PreviousRunner is non-nil if Alloc has a PreviousAllocation and it is
	// running locally.
	PreviousRunner AllocRunnerMeta

	// PreemptedRunners is non-nil if Alloc has one or more PreemptedAllocations.
	PreemptedRunners map[string]AllocRunnerMeta

	// RPC allows the alloc watcher to monitor remote allocations.
	RPC RPCer

	// Config is necessary for using the RPC.
	Config *config.Config

	// MigrateToken is used to migrate remote alloc dirs when ACLs are
	// enabled.
	MigrateToken string

	Logger hclog.Logger
}

type NoopPrevAlloc

type NoopPrevAlloc struct{}

NoopPrevAlloc does not block or migrate on a previous allocation and never returns an error.

func (NoopPrevAlloc) IsMigrating

func (NoopPrevAlloc) IsMigrating() bool

func (NoopPrevAlloc) IsWaiting

func (NoopPrevAlloc) IsWaiting() bool

func (NoopPrevAlloc) Migrate

Migrate returns nil immediately.

func (NoopPrevAlloc) Wait

Wait returns nil immediately.

type RPCer

type RPCer interface {
	// RPC allows retrieving remote allocs.
	RPC(method string, args interface{}, reply interface{}) error
}

RPCer is the interface needed by a prevAllocWatcher to make RPC calls.

Jump to

Keyboard shortcuts

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