vendor c/common@main

Required for using the newly added pod exit policies.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2022-04-29 13:13:39 +02:00
parent 80315b9c86
commit 77d872ea38
16 changed files with 1185 additions and 10 deletions

View File

@ -349,6 +349,9 @@ type EngineConfig struct {
// OCIRuntimes are the set of configured OCI runtimes (default is runc).
OCIRuntimes map[string][]string `toml:"runtimes,omitempty"`
// PodExitPolicy determines the behaviour when the last container of a pod exits.
PodExitPolicy PodExitPolicy `toml:"pod_exit_policy,omitempty"`
// PullPolicy determines whether to pull image before creating or running a container
// default is "missing"
PullPolicy string `toml:"pull_policy,omitempty"`

View File

@ -506,6 +506,9 @@ default_sysctls = [
#
#num_locks = 2048
# Set the exit policy of the pod when the last container exits.
#pod_exit_policy = "continue"
# Whether to pull new image before running a container
#
#pull_policy = "missing"

View File

@ -388,6 +388,8 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
c.MachineEnabled = false
c.ChownCopiedFiles = true
c.PodExitPolicy = defaultPodExitPolicy
return c, nil
}

View File

@ -0,0 +1,36 @@
package config
import "fmt"
// PodExitPolicies includes the supported pod exit policies.
var PodExitPolicies = []string{string(PodExitPolicyContinue), string(PodExitPolicyStop)}
// PodExitPolicy determines a pod's exit and stop behaviour.
type PodExitPolicy string
const (
// PodExitPolicyContinue instructs the pod to continue running when the
// last container has exited.
PodExitPolicyContinue PodExitPolicy = "continue"
// PodExitPolicyStop instructs the pod to stop when the last container
// has exited.
PodExitPolicyStop = "stop"
// PodExitPolicyUnsupported implies an internal error.
// Negative for backwards compat.
PodExitPolicyUnsupported = "invalid"
defaultPodExitPolicy = PodExitPolicyContinue
)
// ParsePodExitPolicy parses the specified policy and returns an error if it is
// invalid.
func ParsePodExitPolicy(policy string) (PodExitPolicy, error) {
switch policy {
case "", string(PodExitPolicyContinue):
return PodExitPolicyContinue, nil
case string(PodExitPolicyStop):
return PodExitPolicyStop, nil
default:
return PodExitPolicyUnsupported, fmt.Errorf("invalid pod exit policy: %q", policy)
}
}