restarts

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReasonNoRestartsAllowed   = "Policy allows no restarts"
	ReasonUnrecoverableErrror = "Error was unrecoverable"
	ReasonWithinPolicy        = "Restart within policy"
	ReasonDelay               = "Exceeded allowed attempts, applying a delay"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RestartTracker

type RestartTracker struct {
	// contains filtered or unexported fields
}

func NewRestartTracker

func NewRestartTracker(policy *structs.RestartPolicy, jobType string) *RestartTracker

func (*RestartTracker) GetCount

func (r *RestartTracker) GetCount() int

GetCount returns the current restart count

func (*RestartTracker) GetPolicy

func (r *RestartTracker) GetPolicy() *structs.RestartPolicy

GetPolicy returns a copy of the policy used to determine restarts.

func (*RestartTracker) GetReason

func (r *RestartTracker) GetReason() string

GetReason returns a human-readable description for the last state returned by GetState.

func (*RestartTracker) GetState

func (r *RestartTracker) GetState() (string, time.Duration)

GetState returns the tasks next state given the set exit code and start error. One of the following states are returned:

  • TaskRestarting - Task should be restarted
  • TaskNotRestarting - Task should not be restarted and has exceeded its restart policy.
  • TaskTerminated - Task has terminated successfully and does not need a restart.

If TaskRestarting is returned, the duration is how long to wait until starting the task again.

func (*RestartTracker) SetExitResult

func (r *RestartTracker) SetExitResult(res *drivers.ExitResult) *RestartTracker

SetExitResult is used to mark the most recent wait result.

func (*RestartTracker) SetKilled

func (r *RestartTracker) SetKilled() *RestartTracker

SetKilled is used to mark that the task has been killed.

func (*RestartTracker) SetPolicy

func (r *RestartTracker) SetPolicy(policy *structs.RestartPolicy)

SetPolicy updates the policy used to determine restarts.

func (*RestartTracker) SetRestartTriggered

func (r *RestartTracker) SetRestartTriggered(failure bool) *RestartTracker

SetRestartTriggered is used to mark that the task has been signalled to be restarted. Setting the failure to true restarts according to the restart policy. When failure is false the task is restarted without considering the restart policy.

func (*RestartTracker) SetStartError

func (r *RestartTracker) SetStartError(err error) *RestartTracker

SetStartError is used to mark the most recent start error. If starting was successful the error should be nil.

Jump to

Keyboard shortcuts

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