restart

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package restart enables containers to have labels added and monitored to keep the container's task running if it is killed.

Setting the StatusLabel on a container instructs the restart monitor to keep that container's task in a specific status. Setting the LogPathLabel on a container will setup the task's IO to be redirected to a log file when running a task within the restart manager.

The restart labels can be cleared off of a container using the WithNoRestarts Opt.

The restart monitor has one option in the containerd config under the [plugins.restart] section. `interval = "10s" sets the reconcile interval that the restart monitor checks for task state and reconciles the desired status for that task.

Index

Constants

View Source
const (
	// StatusLabel sets the restart status label for a container
	StatusLabel = "containerd.io/restart.status"
	// LogURILabel sets the restart log uri label for a container
	LogURILabel = "containerd.io/restart.loguri"

	// PolicyLabel sets the restart policy label for a container
	PolicyLabel = "containerd.io/restart.policy"
	// CountLabel sets the restart count label for a container
	CountLabel = "containerd.io/restart.count"
	// ExplicitlyStoppedLabel sets the restart explicitly stopped label for a container
	ExplicitlyStoppedLabel = "containerd.io/restart.explicitly-stopped"

	// LogPathLabel sets the restart log path label for a container
	//
	// Deprecated(in release 1.5): use LogURILabel
	LogPathLabel = "containerd.io/restart.logpath"
)

Variables

This section is empty.

Functions

func Reconcile added in v1.6.9

func Reconcile(status containerd.Status, labels map[string]string) bool

Reconcile reconciles the restart policy of a container.

func WithBinaryLogURI added in v1.4.0

func WithBinaryLogURI(binary string, args map[string]string) func(context.Context, *containerd.Client, *containers.Container) error

WithBinaryLogURI sets the binary-type log uri for a container.

Deprecated(in release 1.5): use WithLogURI

func WithFileLogURI added in v1.4.0

func WithFileLogURI(path string) func(context.Context, *containerd.Client, *containers.Container) error

WithFileLogURI sets the file-type log uri for a container.

Deprecated(in release 1.5): use WithLogURI

func WithLogPath

func WithLogPath(path string) func(context.Context, *containerd.Client, *containers.Container) error

WithLogPath sets the log path for a container

Deprecated(in release 1.5): use WithLogURI with "file://<path>" URI.

func WithLogURI added in v1.6.9

func WithLogURI(uri *url.URL) func(context.Context, *containerd.Client, *containers.Container) error

WithLogURI sets the specified log uri for a container.

func WithLogURIString added in v1.6.9

func WithLogURIString(uriString string) func(context.Context, *containerd.Client, *containers.Container) error

WithLogURIString sets the specified log uri string for a container.

func WithNoRestarts

func WithNoRestarts(_ context.Context, _ *containerd.Client, c *containers.Container) error

WithNoRestarts clears any restart information from the container

func WithPolicy added in v1.6.9

func WithPolicy(policy *Policy) func(context.Context, *containerd.Client, *containers.Container) error

WithPolicy sets the restart policy for a container

func WithStatus

WithStatus sets the status for a container

Types

type Policy added in v1.6.9

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

Policy represents the restart policies of a container.

func NewPolicy added in v1.6.9

func NewPolicy(policy string) (*Policy, error)

NewPolicy creates a restart policy with the specified name. supports the following restart policies: - no, Do not restart the container. - always, Always restart the container regardless of the exit status. - on-failure[:max-retries], Restart only if the container exits with a non-zero exit status. - unless-stopped, Always restart the container unless it is stopped.

func (*Policy) MaximumRetryCount added in v1.6.9

func (rp *Policy) MaximumRetryCount() int

func (*Policy) Name added in v1.6.9

func (rp *Policy) Name() string

func (*Policy) String added in v1.6.9

func (rp *Policy) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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