goalstate

package
v0.0.0-...-a69e935 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 13 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostChangePool

func HostChangePool(ctx context.Context, entity goalstate.Entity) error

HostChangePool action will set the host's current pool to its desired pool And update the goal state to UP and enqueue the host to reevaluation.

func HostDown

func HostDown(ctx context.Context, entity goalstate.Entity) error

HostDown is an idempotent action registering the host as DOWN in maintenance

func HostDrain

func HostDrain(ctx context.Context, entity goalstate.Entity) error

HostDrain is an idempotent action enqueuing the host for draining of its tasks

func HostInvalidAction

func HostInvalidAction(ctx context.Context, entity goalstate.Entity) error

HostInvalidAction action is a error state transition and should not happen

func HostRequeue

func HostRequeue(ctx context.Context, entity goalstate.Entity) error

HostRequeue re-enqueues the host into the goal state engine This is needed as host entity GetState() & GetGoalState() are reads from DB which can error out (e.g. DB unavailable), the retry mechanism is handled by re-enqueuing into the goal state engine. TODO: remove once host state & goalState backed by host cache

func HostTriggerMaintenance

func HostTriggerMaintenance(ctx context.Context, entity goalstate.Entity) error

HostTriggerMaintenance will make the goal state to DOWN by that we can start draining

func HostUntrack

func HostUntrack(ctx context.Context, entity goalstate.Entity) error

HostUntrack untracks the host by removing it from the goal state engine's entity map

func HostUp

func HostUp(ctx context.Context, entity goalstate.Entity) error

HostUp is an idempotent action registering the host as UP, out of maintenance

func NewHostEntity

func NewHostEntity(hostname string, driver *driver) goalstate.Entity

NewHostEntity implements the goal state Entity interface for hosts.

Types

type Config

type Config struct {
	// MaxRetryDelay is the absolute maximum duration between any retry, capping
	// any backoff to this amount.
	MaxRetryDelay time.Duration `yaml:"max_retry_delay"`
	// FailureRetryDelay is the delay for retry, if an operation failed. Backoff
	// will be applied for up to MaxRetryDelay.
	FailureRetryDelay time.Duration `yaml:"failure_retry_delay"`

	NumWorkerHostThreads int `yaml:"host_worker_thread_count"`
}

Config for the goalstate engine.

type Driver

type Driver interface {
	// EnqueueHost is used to enqueue a host into the goal state.
	EnqueueHost(hostname string, deadline time.Time)

	// DeleteHost deletes the host from the goal state engine.
	DeleteHost(hostname string)

	// Start is used to start processing items in the goal state engine.
	Start()

	// Stop is used to clean all items and then stop the goal state engine.
	Stop()

	// Started returns true if goal state engine has finished start process
	Started() bool
}

Driver is the interface to enqueue hosts into the goal state engine for evaluation and then run the corresponding actions.

func NewDriver

func NewDriver(
	hostInfoOps ormobjects.HostInfoOps,
	mesosMasterClient mpb.MasterOperatorClient,
	parentScope tally.Scope,
	cfg Config,
	hostpoolManager manager.HostPoolManager,
) Driver

NewDriver returns a new goal state driver object.

type HostAction

type HostAction string

HostAction is a string for host actions.

const (
	// NoAction implies do not take any action
	NoAction HostAction = "noop"
	// DrainAction enqueues the host for draining its tasks
	DrainAction HostAction = "drain"
	// DownAction registers the host as DOWN, in maintenance
	DownAction HostAction = "down"
	// UpAction registers the host as UP, out of maintenance
	UpAction HostAction = "up"
	// RequeueAction re-enqueues the host into the goal state engine
	// This is needed as host entity GetState() & GetGoalState() are reads from DB
	// which can error out (e.g. DB unavailable), the retry mechanism is handled by
	// re-enqueing into the goal state engine.
	// TODO: remove once host state & goalState backed by host cache
	RequeueAction HostAction = "reenqueue"
	// UntrackAction untracks the host by removing it
	// from the goal state engine's entity map
	UntrackAction HostAction = "untrack"

	// ChangePoolAction is to change the host pool of the
	// host. This action will do two things
	// 1. Change the current pool in db as desired pool
	// 2. Make the goal state to Up and reenqueue
	ChangePoolAction HostAction = "ChangePool"

	// StartMaintenanceAction is to start the Maintenance
	// if we find pool is not equal to desired pool
	StartMaintenanceAction HostAction = "StartMaintenance"

	// InvalidAction is a invalid action and this should not occur
	InvalidAction HostAction = "InvalidAction"
)

Jump to

Keyboard shortcuts

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