Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RestartPolicy ¶
type RestartPolicy struct {
Enabled bool `json:"enabled"`
IgnoredExitCodes []int `json:"ignoredExitCodes"`
RestartAttemptPeriod int `json:"restartAttemptPeriod"`
}
RestartPolicy represents a policy that contains key information considered when deciding whether or not a container should be restarted after it has exited.
type RestartTracker ¶
type RestartTracker struct {
RestartCount int `json:"restartCount,omitempty"`
LastRestartAt time.Time `json:"lastRestartAt,omitempty"`
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"`
// contains filtered or unexported fields
}
func NewRestartTracker ¶
func NewRestartTracker(restartPolicy RestartPolicy) *RestartTracker
func (*RestartTracker) GetLastRestartAt ¶
func (rt *RestartTracker) GetLastRestartAt() time.Time
func (*RestartTracker) GetRestartCount ¶
func (rt *RestartTracker) GetRestartCount() int
func (*RestartTracker) RecordRestart ¶
func (rt *RestartTracker) RecordRestart()
RecordRestart updates the restart tracker's metadata after a restart has occurred. This metadata is used to calculate when restarts should occur and track how many have occurred. It is not the job of this method to determine if a restart should occur or restart the container.
func (*RestartTracker) ShouldRestart ¶
func (rt *RestartTracker) ShouldRestart(exitCode *int, startedAt time.Time, desiredStatus apicontainerstatus.ContainerStatus) (bool, string)
ShouldRestart returns whether the container should restart and a reason string explaining why not. The reset attempt period will be calculated first with LastRestart at, using the passed in startedAt if it does not exist.