Documentation ¶
Index ¶
- type Supervisor
- func (r *Supervisor) Cancel(taskID string)
- func (r *Supervisor) CancelAll()
- func (r *Supervisor) ClearServiceHistory(serviceID string)
- func (r *Supervisor) DelayStart(ctx context.Context, _ store.Tx, oldTask *api.Task, newTaskID string, ...) <-chan struct{}
- func (r *Supervisor) RecordRestartHistory(tuple orchestrator.SlotTuple, replacementTask *api.Task)
- func (r *Supervisor) Restart(ctx context.Context, tx store.Tx, cluster *api.Cluster, service *api.Service, ...) error
- func (r *Supervisor) StartNow(tx store.Tx, taskID string) error
- func (r *Supervisor) UpdatableTasksInSlot(ctx context.Context, slot orchestrator.Slot, service *api.Service) orchestrator.Slot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Supervisor ¶
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.