restart

package
v0.0.0-...-3e31364 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Supervisor

type Supervisor struct {
	TaskTimeout time.Duration
	// contains filtered or unexported fields
}

Supervisor initiates and manages restarts. It's responsible for delaying restarts when applicable.

func NewSupervisor

func NewSupervisor(store *store.MemoryStore) *Supervisor

NewSupervisor creates a new RestartSupervisor.

func (*Supervisor) Cancel

func (r *Supervisor) Cancel(taskID string)

Cancel cancels a pending restart.

func (*Supervisor) CancelAll

func (r *Supervisor) CancelAll()

CancelAll aborts all pending restarts

func (*Supervisor) ClearServiceHistory

func (r *Supervisor) ClearServiceHistory(serviceID string)

ClearServiceHistory forgets restart history related to a given service ID.

func (*Supervisor) DelayStart

func (r *Supervisor) DelayStart(ctx context.Context, _ store.Tx, oldTask *api.Task, newTaskID string, delay time.Duration, waitStop bool) <-chan struct{}

DelayStart starts a timer that moves the task from READY to RUNNING once: - The restart delay has elapsed (if applicable) - The old task that it's replacing has stopped running (or this times out) It must be called during an Update transaction to ensure that it does not miss events. The purpose of the store.Tx argument is to avoid accidental calls outside an Update transaction.

func (*Supervisor) RecordRestartHistory

func (r *Supervisor) RecordRestartHistory(tuple orchestrator.SlotTuple, replacementTask *api.Task)

RecordRestartHistory updates the historyByService map to reflect the restart of restartedTask.

func (*Supervisor) Restart

func (r *Supervisor) Restart(ctx context.Context, tx store.Tx, cluster *api.Cluster, service *api.Service, t api.Task) error

Restart initiates a new task to replace t if appropriate under the service's restart policy.

func (*Supervisor) StartNow

func (r *Supervisor) StartNow(tx store.Tx, taskID string) error

StartNow moves the task into the RUNNING state so it will proceed to start up.

func (*Supervisor) UpdatableTasksInSlot

func (r *Supervisor) UpdatableTasksInSlot(ctx context.Context, slot orchestrator.Slot, service *api.Service) orchestrator.Slot

UpdatableTasksInSlot returns the set of tasks that should be passed to the updater from this slot, or an empty slice if none should be. An updatable slot has either at least one task that with desired state <= RUNNING, or its most recent task has stopped running and should not be restarted. The latter case is for making sure that tasks that shouldn't normally be restarted will still be handled by rolling updates when they become outdated. There is a special case for rollbacks to make sure that a rollback always takes the service to a converged state, instead of ignoring tasks with the original spec that stopped running and shouldn't be restarted according to the restart policy.

type SupervisorInterface

type SupervisorInterface interface {
	Restart(context.Context, store.Tx, *api.Cluster, *api.Service, api.Task) error
	UpdatableTasksInSlot(context.Context, orchestrator.Slot, *api.Service) orchestrator.Slot
	RecordRestartHistory(orchestrator.SlotTuple, *api.Task)
	DelayStart(context.Context, store.Tx, *api.Task, string, time.Duration, bool) <-chan struct{}
	StartNow(store.Tx, string) error
	Cancel(string)
	CancelAll()
	ClearServiceHistory(string)
}

SupervisorInterface is an interface implemented by the Supervisor. It exists to make testing easier, by allowing the restart supervisor to be mocked or faked where desired.

Jump to

Keyboard shortcuts

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