allocwatcher

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 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

func NewAllocWatcher(c Config) (PrevAllocWatcher, PrevAllocMigrator)

NewAllocWatcher creates a PrevAllocWatcher appropriate for whether this alloc's previous allocation was local or remote. If this alloc has no previous alloc then a noop implementation is returned.

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 PrevAllocMigrator

type PrevAllocMigrator interface {
	PrevAllocWatcher

	// IsMigrating returns true if a concurrent caller is in Migrate
	IsMigrating() bool

	// Migrate data from previous alloc
	Migrate(ctx context.Context, dest *allocdir.AllocDir) error
}

PrevAllocMigrator allows AllocRunners to migrate a previous allocation whether or not the previous allocation is local or remote.

type PrevAllocWatcher

type PrevAllocWatcher interface {
	// Wait for previous alloc to terminate
	Wait(context.Context) error

	// IsWaiting returns true if a concurrent caller is blocked in Wait
	IsWaiting() bool
}

PrevAllocWatcher allows AllocRunners to wait for a previous allocation to terminate whether or not the previous allocation is local or remote. See `PrevAllocMigrator` for migrating workloads.

func NewGroupAllocWatcher

func NewGroupAllocWatcher(watchers ...PrevAllocWatcher) PrevAllocWatcher

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