mirror of
https://github.com/containers/podman.git
synced 2025-06-29 06:57:13 +08:00
Change pause container to infra container
Signed-off-by: haircommander <pehunt@redhat.com> Closes: #1187 Approved by: mheon
This commit is contained in:

committed by
Atomic Bot

parent
697b46430a
commit
2a7449362f
@ -125,12 +125,12 @@ func GetRuntimeWithStorageOpts(c *cli.Context, storageOpts *storage.StoreOptions
|
|||||||
// TODO flag to set CNI plugins dir?
|
// TODO flag to set CNI plugins dir?
|
||||||
|
|
||||||
// Pod create options
|
// Pod create options
|
||||||
if c.IsSet("pause-image") {
|
if c.IsSet("infra-image") {
|
||||||
options = append(options, libpod.WithDefaultPauseImage(c.String("pause-image")))
|
options = append(options, libpod.WithDefaultInfraImage(c.String("infra-image")))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.IsSet("pause-command") {
|
if c.IsSet("infra-command") {
|
||||||
options = append(options, libpod.WithDefaultPauseCommand(c.String("pause-command")))
|
options = append(options, libpod.WithDefaultInfraCommand(c.String("infra-command")))
|
||||||
}
|
}
|
||||||
|
|
||||||
return libpod.NewRuntime(options...)
|
return libpod.NewRuntime(options...)
|
||||||
|
@ -28,6 +28,18 @@ var podCreateFlags = []cli.Flag{
|
|||||||
Name: "cgroup-parent",
|
Name: "cgroup-parent",
|
||||||
Usage: "Set parent cgroup for the pod",
|
Usage: "Set parent cgroup for the pod",
|
||||||
},
|
},
|
||||||
|
cli.BoolTFlag{
|
||||||
|
Name: "infra",
|
||||||
|
Usage: "Create an infra container associated with the pod to share namespaces with",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "infra-image",
|
||||||
|
Usage: "The image of the infra container to associate with the pod",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "infra-command",
|
||||||
|
Usage: "The command to run on the infra container when the pod is started",
|
||||||
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
Name: "label-file",
|
Name: "label-file",
|
||||||
Usage: "Read in a line delimited file of labels (default [])",
|
Usage: "Read in a line delimited file of labels (default [])",
|
||||||
@ -40,18 +52,6 @@ var podCreateFlags = []cli.Flag{
|
|||||||
Name: "name, n",
|
Name: "name, n",
|
||||||
Usage: "Assign a name to the pod",
|
Usage: "Assign a name to the pod",
|
||||||
},
|
},
|
||||||
cli.BoolTFlag{
|
|
||||||
Name: "pause",
|
|
||||||
Usage: "Create a pause container associated with the pod to share namespaces with",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "pause-image",
|
|
||||||
Usage: "The image of the pause container to associate with the pod",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "pause-command",
|
|
||||||
Usage: "The command to run on the pause container when the pod is started",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "pod-id-file",
|
Name: "pod-id-file",
|
||||||
Usage: "Write the pod ID to the file",
|
Usage: "Write the pod ID to the file",
|
||||||
@ -95,8 +95,8 @@ func podCreateCmd(c *cli.Context) error {
|
|||||||
return errors.Wrapf(err, "unable to write pod id file %s", c.String("pod-id-file"))
|
return errors.Wrapf(err, "unable to write pod id file %s", c.String("pod-id-file"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !c.BoolT("pause") && c.IsSet("share") && c.String("share") != "none" && c.String("share") != "" {
|
if !c.BoolT("infra") && c.IsSet("share") && c.String("share") != "none" && c.String("share") != "" {
|
||||||
return errors.Errorf("You cannot share kernel namespaces on the pod level without a pause container")
|
return errors.Errorf("You cannot share kernel namespaces on the pod level without an infra container")
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.IsSet("cgroup-parent") {
|
if c.IsSet("cgroup-parent") {
|
||||||
@ -115,8 +115,8 @@ func podCreateCmd(c *cli.Context) error {
|
|||||||
options = append(options, libpod.WithPodName(c.String("name")))
|
options = append(options, libpod.WithPodName(c.String("name")))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.BoolT("pause") {
|
if c.BoolT("infra") {
|
||||||
options = append(options, libpod.WithPauseContainer())
|
options = append(options, libpod.WithInfraContainer())
|
||||||
nsOptions, err := shared.GetNamespaceOptions(strings.Split(c.String("share"), ","))
|
nsOptions, err := shared.GetNamespaceOptions(strings.Split(c.String("share"), ","))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -57,7 +57,7 @@ type podPsTemplateParams struct {
|
|||||||
Status string
|
Status string
|
||||||
Cgroup string
|
Cgroup string
|
||||||
ContainerInfo string
|
ContainerInfo string
|
||||||
PauseContainerID string
|
InfraContainerID string
|
||||||
SharedNamespaces string
|
SharedNamespaces string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ type podPsJSONParams struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
CtrsInfo []podPsCtrInfo `json:"containerinfo,omitempty"`
|
CtrsInfo []podPsCtrInfo `json:"containerinfo,omitempty"`
|
||||||
Cgroup string `json:"cgroup,omitempty"`
|
Cgroup string `json:"cgroup,omitempty"`
|
||||||
PauseContainerID string `json:"pausecontainerid,omitempty"`
|
InfraContainerID string `json:"infracontainerid,omitempty"`
|
||||||
SharedNamespaces []string `json:"sharednamespaces,omitempty"`
|
SharedNamespaces []string `json:"sharednamespaces,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ func genPodPsFormat(c *cli.Context) string {
|
|||||||
} else {
|
} else {
|
||||||
format += "\t{{.NumberOfContainers}}"
|
format += "\t{{.NumberOfContainers}}"
|
||||||
}
|
}
|
||||||
format += "\t{{.PauseContainerID}}"
|
format += "\t{{.InfraContainerID}}"
|
||||||
}
|
}
|
||||||
return format
|
return format
|
||||||
}
|
}
|
||||||
@ -418,7 +418,7 @@ func getPodTemplateOutput(psParams []podPsJSONParams, opts podPsOptions) ([]podP
|
|||||||
|
|
||||||
for _, psParam := range psParams {
|
for _, psParam := range psParams {
|
||||||
podID := psParam.ID
|
podID := psParam.ID
|
||||||
pauseID := psParam.PauseContainerID
|
infraID := psParam.InfraContainerID
|
||||||
var ctrStr string
|
var ctrStr string
|
||||||
|
|
||||||
truncated := ""
|
truncated := ""
|
||||||
@ -428,7 +428,7 @@ func getPodTemplateOutput(psParams []podPsJSONParams, opts podPsOptions) ([]podP
|
|||||||
psParam.CtrsInfo = psParam.CtrsInfo[:NUM_CTR_INFO]
|
psParam.CtrsInfo = psParam.CtrsInfo[:NUM_CTR_INFO]
|
||||||
truncated = "..."
|
truncated = "..."
|
||||||
}
|
}
|
||||||
pauseID = shortID(pauseID)
|
infraID = shortID(infraID)
|
||||||
}
|
}
|
||||||
for _, ctrInfo := range psParam.CtrsInfo {
|
for _, ctrInfo := range psParam.CtrsInfo {
|
||||||
ctrStr += "[ "
|
ctrStr += "[ "
|
||||||
@ -456,7 +456,7 @@ func getPodTemplateOutput(psParams []podPsJSONParams, opts podPsOptions) ([]podP
|
|||||||
NumberOfContainers: psParam.NumberOfContainers,
|
NumberOfContainers: psParam.NumberOfContainers,
|
||||||
Cgroup: psParam.Cgroup,
|
Cgroup: psParam.Cgroup,
|
||||||
ContainerInfo: ctrStr,
|
ContainerInfo: ctrStr,
|
||||||
PauseContainerID: pauseID,
|
InfraContainerID: infraID,
|
||||||
SharedNamespaces: strings.Join(psParam.SharedNamespaces, ","),
|
SharedNamespaces: strings.Join(psParam.SharedNamespaces, ","),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ func getAndSortPodJSONParams(pods []*libpod.Pod, opts podPsOptions, runtime *lib
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pauseContainerID, err := pod.PauseContainerID()
|
infraContainerID, err := pod.InfraContainerID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -547,7 +547,7 @@ func getAndSortPodJSONParams(pods []*libpod.Pod, opts podPsOptions, runtime *lib
|
|||||||
NumberOfContainers: ctrNum,
|
NumberOfContainers: ctrNum,
|
||||||
CtrsInfo: ctrsInfo,
|
CtrsInfo: ctrsInfo,
|
||||||
SharedNamespaces: getSharedNamespaces(pod),
|
SharedNamespaces: getSharedNamespaces(pod),
|
||||||
PauseContainerID: pauseContainerID,
|
InfraContainerID: infraContainerID,
|
||||||
}
|
}
|
||||||
|
|
||||||
psOutput = append(psOutput, params)
|
psOutput = append(psOutput, params)
|
||||||
|
@ -44,7 +44,7 @@ type psTemplateParams struct {
|
|||||||
User string
|
User string
|
||||||
UTS string
|
UTS string
|
||||||
Pod string
|
Pod string
|
||||||
IsPause bool
|
IsInfra bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// psJSONParams is used as a base structure for the psParams
|
// psJSONParams is used as a base structure for the psParams
|
||||||
@ -72,7 +72,7 @@ type psJSONParams struct {
|
|||||||
ContainerRunning bool `json:"ctrRunning"`
|
ContainerRunning bool `json:"ctrRunning"`
|
||||||
Namespaces *shared.Namespace `json:"namespace,omitempty"`
|
Namespaces *shared.Namespace `json:"namespace,omitempty"`
|
||||||
Pod string `json:"pod,omitempty"`
|
Pod string `json:"pod,omitempty"`
|
||||||
IsPause bool `json:"pause"`
|
IsInfra bool `json:"infra"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type declaration and functions for sorting the PS output
|
// Type declaration and functions for sorting the PS output
|
||||||
@ -241,8 +241,8 @@ func psCmd(c *cli.Context) error {
|
|||||||
// only get running containers
|
// only get running containers
|
||||||
filterFuncs = append(filterFuncs, func(c *libpod.Container) bool {
|
filterFuncs = append(filterFuncs, func(c *libpod.Container) bool {
|
||||||
state, _ := c.State()
|
state, _ := c.State()
|
||||||
// Don't return pause containers
|
// Don't return infra containers
|
||||||
return state == libpod.ContainerStateRunning && !c.IsPause()
|
return state == libpod.ContainerStateRunning && !c.IsInfra()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ func generateContainerFilterFuncs(filter, filterValue string, runtime *libpod.Ru
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate the template based on conditions given
|
// generate the template based on conditions given
|
||||||
func genPsFormat(format string, quiet, size, namespace, pod, pause bool) string {
|
func genPsFormat(format string, quiet, size, namespace, pod, infra bool) string {
|
||||||
if format != "" {
|
if format != "" {
|
||||||
// "\t" from the command line is not being recognized as a tab
|
// "\t" from the command line is not being recognized as a tab
|
||||||
// replacing the string "\t" to a tab character if the user passes in "\t"
|
// replacing the string "\t" to a tab character if the user passes in "\t"
|
||||||
@ -441,8 +441,8 @@ func genPsFormat(format string, quiet, size, namespace, pod, pause bool) string
|
|||||||
if size {
|
if size {
|
||||||
format += "{{.Size}}\t"
|
format += "{{.Size}}\t"
|
||||||
}
|
}
|
||||||
if pause {
|
if infra {
|
||||||
format += "{{.IsPause}}\t"
|
format += "{{.IsInfra}}\t"
|
||||||
}
|
}
|
||||||
return format
|
return format
|
||||||
}
|
}
|
||||||
@ -578,7 +578,7 @@ func getTemplateOutput(psParams []psJSONParams, opts shared.PsOptions) ([]psTemp
|
|||||||
Mounts: getMounts(psParam.Mounts, opts.NoTrunc),
|
Mounts: getMounts(psParam.Mounts, opts.NoTrunc),
|
||||||
PID: psParam.PID,
|
PID: psParam.PID,
|
||||||
Pod: pod,
|
Pod: pod,
|
||||||
IsPause: psParam.IsPause,
|
IsInfra: psParam.IsInfra,
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Namespace {
|
if opts.Namespace {
|
||||||
@ -635,7 +635,7 @@ func getAndSortJSONParams(containers []*libpod.Container, opts shared.PsOptions)
|
|||||||
ContainerRunning: batchInfo.ConState == libpod.ContainerStateRunning,
|
ContainerRunning: batchInfo.ConState == libpod.ContainerStateRunning,
|
||||||
Namespaces: ns,
|
Namespaces: ns,
|
||||||
Pod: ctr.PodID(),
|
Pod: ctr.PodID(),
|
||||||
IsPause: ctr.IsPause(),
|
IsInfra: ctr.IsInfra(),
|
||||||
}
|
}
|
||||||
|
|
||||||
psOutput = append(psOutput, params)
|
psOutput = append(psOutput, params)
|
||||||
|
@ -343,7 +343,7 @@ type PodCreate (
|
|||||||
cgroupParent: string,
|
cgroupParent: string,
|
||||||
labels: [string]string,
|
labels: [string]string,
|
||||||
share: []string,
|
share: []string,
|
||||||
pause: bool
|
infra: bool
|
||||||
)
|
)
|
||||||
|
|
||||||
# ListPodData is the returned struct for an individual pod
|
# ListPodData is the returned struct for an individual pod
|
||||||
@ -656,7 +656,7 @@ method PullImage(name: string) -> (id: string)
|
|||||||
# "pod": "b05dee7bd4ccfee688099fe1588a7a898d6ddd6897de9251d4671c9b0feacb2a"
|
# "pod": "b05dee7bd4ccfee688099fe1588a7a898d6ddd6897de9251d4671c9b0feacb2a"
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# $ varlink call unix:/run/podman/io.podman/io.podman.CreatePod '{"create": {"pause": true, "share": ["ipc", "net", "uts"]}}'
|
# $ varlink call unix:/run/podman/io.podman/io.podman.CreatePod '{"create": {"infra": true, "share": ["ipc", "net", "uts"]}}'
|
||||||
# {
|
# {
|
||||||
# "pod": "d7697449a8035f613c1a8891286502aca68fff7d5d49a85279b3bda229af3b28"
|
# "pod": "d7697449a8035f613c1a8891286502aca68fff7d5d49a85279b3bda229af3b28"
|
||||||
# }
|
# }
|
||||||
|
@ -2077,9 +2077,9 @@ _podman_logout() {
|
|||||||
_podman_pod_create() {
|
_podman_pod_create() {
|
||||||
local options_with_args="
|
local options_with_args="
|
||||||
--cgroup-parent
|
--cgroup-parent
|
||||||
|
--infra-command
|
||||||
|
--infra-image
|
||||||
--share
|
--share
|
||||||
--pause-command
|
|
||||||
--pause-image
|
|
||||||
--podidfile
|
--podidfile
|
||||||
--label-file
|
--label-file
|
||||||
--label
|
--label
|
||||||
@ -2088,7 +2088,7 @@ _podman_pod_create() {
|
|||||||
"
|
"
|
||||||
|
|
||||||
local boolean_options="
|
local boolean_options="
|
||||||
--pause
|
--infra
|
||||||
"
|
"
|
||||||
_complete_ "$options_with_args" "$boolean_options"
|
_complete_ "$options_with_args" "$boolean_options"
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,22 @@ containers added to it. The pod id is printed to STDOUT. You can then use
|
|||||||
|
|
||||||
Path to cgroups under which the cgroup for the pod will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
|
Path to cgroups under which the cgroup for the pod will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
|
||||||
|
|
||||||
**--podidfile**=""
|
|
||||||
|
|
||||||
Write the pod ID to the file
|
|
||||||
|
|
||||||
**--help**
|
**--help**
|
||||||
|
|
||||||
Print usage statement
|
Print usage statement
|
||||||
|
|
||||||
|
**--infra**
|
||||||
|
|
||||||
|
Create an infra container and associate it with the pod. An infra container is a lightweight container used to coordinate the shared kernel namespace of a pod. Default: true
|
||||||
|
|
||||||
|
**--infra-command**=""
|
||||||
|
|
||||||
|
The command that will be run to start the infra container. Default: "/pause"
|
||||||
|
|
||||||
|
**--infra-image**=""
|
||||||
|
|
||||||
|
The image that will be created for the infra container. Default: "k8s.gcr.io/pause:3.1"
|
||||||
|
|
||||||
**-l**, **--label**=[]
|
**-l**, **--label**=[]
|
||||||
|
|
||||||
Add metadata to a pod (e.g., --label com.example.key=value)
|
Add metadata to a pod (e.g., --label com.example.key=value)
|
||||||
@ -39,17 +47,9 @@ Read in a line delimited file of labels
|
|||||||
|
|
||||||
Assign a name to the pod
|
Assign a name to the pod
|
||||||
|
|
||||||
**--pause**
|
**--podidfile**=""
|
||||||
|
|
||||||
Create a pause container and associate it with the pod. A pause container is a lightweight container used to coordinate the shared kernel namespace of a pod. Default: true
|
Write the pod ID to the file
|
||||||
|
|
||||||
**--pause-command**=""
|
|
||||||
|
|
||||||
The command that will be run to start the pause container. Default: "/pause"
|
|
||||||
|
|
||||||
**--pause-image**=""
|
|
||||||
|
|
||||||
The image that will be created for the pause container. Default: "k8s.gcr.io/pause:3.1"
|
|
||||||
|
|
||||||
**--share**=""
|
**--share**=""
|
||||||
|
|
||||||
@ -69,9 +69,9 @@ for it. The name is useful any place you need to identify a pod.
|
|||||||
|
|
||||||
# podman pod create --name test
|
# podman pod create --name test
|
||||||
|
|
||||||
# podman pod create --pause=false
|
# podman pod create --infra=false
|
||||||
|
|
||||||
# podman pod create --pause-command /top
|
# podman pod create --infra-command /top
|
||||||
|
|
||||||
## SEE ALSO
|
## SEE ALSO
|
||||||
podman-pod(1)
|
podman-pod(1)
|
||||||
|
@ -342,9 +342,9 @@ type ContainerConfig struct {
|
|||||||
// It picks up the built-in volumes of the container used by --volumes-from
|
// It picks up the built-in volumes of the container used by --volumes-from
|
||||||
LocalVolumes []string
|
LocalVolumes []string
|
||||||
|
|
||||||
// IsPause is a bool indicating whether this container is a pause container used for
|
// IsInfra is a bool indicating whether this container is an infra container used for
|
||||||
// sharing kernel namespaces in a pod
|
// sharing kernel namespaces in a pod
|
||||||
IsPause bool `json:"pause"`
|
IsInfra bool `json:"pause"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerStatus returns a string representation for users
|
// ContainerStatus returns a string representation for users
|
||||||
@ -974,7 +974,7 @@ func (c *Container) RootGID() int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsPause returns whether the container is a pause container
|
// IsInfra returns whether the container is an infra container
|
||||||
func (c *Container) IsPause() bool {
|
func (c *Container) IsInfra() bool {
|
||||||
return c.config.IsPause
|
return c.config.IsInfra
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT.
|
// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT.
|
||||||
// source: libpod/container.go
|
// source: /home/pehunt/go/src/github.com/containers/libpod/libpod/container.go
|
||||||
|
|
||||||
package libpod
|
package libpod
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ func (j *ContainerConfig) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
|
|||||||
} else {
|
} else {
|
||||||
buf.WriteString(`null`)
|
buf.WriteString(`null`)
|
||||||
}
|
}
|
||||||
if j.IsPause {
|
if j.IsInfra {
|
||||||
buf.WriteString(`,"pause":true`)
|
buf.WriteString(`,"pause":true`)
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(`,"pause":false`)
|
buf.WriteString(`,"pause":false`)
|
||||||
@ -640,7 +640,7 @@ const (
|
|||||||
|
|
||||||
ffjtContainerConfigLocalVolumes
|
ffjtContainerConfigLocalVolumes
|
||||||
|
|
||||||
ffjtContainerConfigIsPause
|
ffjtContainerConfigIsInfra
|
||||||
)
|
)
|
||||||
|
|
||||||
var ffjKeyContainerConfigSpec = []byte("spec")
|
var ffjKeyContainerConfigSpec = []byte("spec")
|
||||||
@ -753,7 +753,7 @@ var ffjKeyContainerConfigExitCommand = []byte("exitCommand")
|
|||||||
|
|
||||||
var ffjKeyContainerConfigLocalVolumes = []byte("LocalVolumes")
|
var ffjKeyContainerConfigLocalVolumes = []byte("LocalVolumes")
|
||||||
|
|
||||||
var ffjKeyContainerConfigIsPause = []byte("pause")
|
var ffjKeyContainerConfigIsInfra = []byte("pause")
|
||||||
|
|
||||||
// UnmarshalJSON umarshall json - template of ffjson
|
// UnmarshalJSON umarshall json - template of ffjson
|
||||||
func (j *ContainerConfig) UnmarshalJSON(input []byte) error {
|
func (j *ContainerConfig) UnmarshalJSON(input []byte) error {
|
||||||
@ -1060,8 +1060,8 @@ mainparse:
|
|||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
|
|
||||||
} else if bytes.Equal(ffjKeyContainerConfigIsPause, kn) {
|
} else if bytes.Equal(ffjKeyContainerConfigIsInfra, kn) {
|
||||||
currentKey = ffjtContainerConfigIsPause
|
currentKey = ffjtContainerConfigIsInfra
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
@ -1152,8 +1152,8 @@ mainparse:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if fflib.EqualFoldRight(ffjKeyContainerConfigIsPause, kn) {
|
if fflib.EqualFoldRight(ffjKeyContainerConfigIsInfra, kn) {
|
||||||
currentKey = ffjtContainerConfigIsPause
|
currentKey = ffjtContainerConfigIsInfra
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
@ -1670,8 +1670,8 @@ mainparse:
|
|||||||
case ffjtContainerConfigLocalVolumes:
|
case ffjtContainerConfigLocalVolumes:
|
||||||
goto handle_LocalVolumes
|
goto handle_LocalVolumes
|
||||||
|
|
||||||
case ffjtContainerConfigIsPause:
|
case ffjtContainerConfigIsInfra:
|
||||||
goto handle_IsPause
|
goto handle_IsInfra
|
||||||
|
|
||||||
case ffjtContainerConfignosuchkey:
|
case ffjtContainerConfignosuchkey:
|
||||||
err = fs.SkipField(tok)
|
err = fs.SkipField(tok)
|
||||||
@ -3973,9 +3973,9 @@ handle_LocalVolumes:
|
|||||||
state = fflib.FFParse_after_value
|
state = fflib.FFParse_after_value
|
||||||
goto mainparse
|
goto mainparse
|
||||||
|
|
||||||
handle_IsPause:
|
handle_IsInfra:
|
||||||
|
|
||||||
/* handler: j.IsPause type=bool kind=bool quoted=false*/
|
/* handler: j.IsInfra type=bool kind=bool quoted=false*/
|
||||||
|
|
||||||
{
|
{
|
||||||
if tok != fflib.FFTok_bool && tok != fflib.FFTok_null {
|
if tok != fflib.FFTok_bool && tok != fflib.FFTok_null {
|
||||||
@ -3991,11 +3991,11 @@ handle_IsPause:
|
|||||||
|
|
||||||
if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 {
|
if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 {
|
||||||
|
|
||||||
j.IsPause = true
|
j.IsInfra = true
|
||||||
|
|
||||||
} else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
|
} else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
|
||||||
|
|
||||||
j.IsPause = false
|
j.IsInfra = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
err = errors.New("unexpected bytes for true/false value")
|
err = errors.New("unexpected bytes for true/false value")
|
||||||
|
@ -104,7 +104,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data)
|
|||||||
IPv6Gateway: "",
|
IPv6Gateway: "",
|
||||||
MacAddress: "", // TODO
|
MacAddress: "", // TODO
|
||||||
},
|
},
|
||||||
IsPause: c.IsPause(),
|
IsInfra: c.IsInfra(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy port mappings into network settings
|
// Copy port mappings into network settings
|
||||||
|
@ -178,7 +178,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
|
|||||||
if err := pod.updatePod(); err != nil {
|
if err := pod.updatePod(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
podInfraContainer = pod.state.PauseContainerID
|
podInfraContainer = pod.state.InfraContainerID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,32 +304,32 @@ func WithNamespace(ns string) RuntimeOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithDefaultPauseImage sets the pause image for libpod.
|
// WithDefaultInfraImage sets the infra image for libpod.
|
||||||
// A pause image is used for inter-container kernel
|
// An infra image is used for inter-container kernel
|
||||||
// namespace sharing within a pod. Typically, a pause
|
// namespace sharing within a pod. Typically, an infra
|
||||||
// container is lightweight and is there to reap
|
// container is lightweight and is there to reap
|
||||||
// zombie processes within its pid namespace.
|
// zombie processes within its pid namespace.
|
||||||
func WithDefaultPauseImage(img string) RuntimeOption {
|
func WithDefaultInfraImage(img string) RuntimeOption {
|
||||||
return func(rt *Runtime) error {
|
return func(rt *Runtime) error {
|
||||||
if rt.valid {
|
if rt.valid {
|
||||||
return ErrRuntimeFinalized
|
return ErrRuntimeFinalized
|
||||||
}
|
}
|
||||||
|
|
||||||
rt.config.PauseImage = img
|
rt.config.InfraImage = img
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithDefaultPauseCommand sets the command to
|
// WithDefaultInfraCommand sets the command to
|
||||||
// run on pause container start up.
|
// run on pause container start up.
|
||||||
func WithDefaultPauseCommand(cmd string) RuntimeOption {
|
func WithDefaultInfraCommand(cmd string) RuntimeOption {
|
||||||
return func(rt *Runtime) error {
|
return func(rt *Runtime) error {
|
||||||
if rt.valid {
|
if rt.valid {
|
||||||
return ErrRuntimeFinalized
|
return ErrRuntimeFinalized
|
||||||
}
|
}
|
||||||
|
|
||||||
rt.config.PauseCommand = cmd
|
rt.config.InfraCommand = cmd
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1156,15 +1156,15 @@ func WithCtrNamespace(ns string) CtrCreateOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// withIsPause sets the container to be a pause container. This means the container will be sometimes hidden
|
// withIsInfra sets the container to be an infra container. This means the container will be sometimes hidden
|
||||||
// and expected to be the first container in the pod.
|
// and expected to be the first container in the pod.
|
||||||
func withIsPause() CtrCreateOption {
|
func withIsInfra() CtrCreateOption {
|
||||||
return func(ctr *Container) error {
|
return func(ctr *Container) error {
|
||||||
if ctr.valid {
|
if ctr.valid {
|
||||||
return ErrCtrFinalized
|
return ErrCtrFinalized
|
||||||
}
|
}
|
||||||
|
|
||||||
ctr.config.IsPause = true
|
ctr.config.IsInfra = true
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1348,14 +1348,14 @@ func WithPodUTS() PodCreateOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithPauseContainer tells the pod to create a pause container
|
// WithInfraContainer tells the pod to create a pause container
|
||||||
func WithPauseContainer() PodCreateOption {
|
func WithInfraContainer() PodCreateOption {
|
||||||
return func(pod *Pod) error {
|
return func(pod *Pod) error {
|
||||||
if pod.valid {
|
if pod.valid {
|
||||||
return ErrPodFinalized
|
return ErrPodFinalized
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.config.PauseContainer.HasPauseContainer = true
|
pod.config.InfraContainer.HasInfraContainer = true
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ type PodConfig struct {
|
|||||||
UsePodUser bool `json:"sharesUser,omitempty"`
|
UsePodUser bool `json:"sharesUser,omitempty"`
|
||||||
UsePodUTS bool `json:"sharesUts,omitempty"`
|
UsePodUTS bool `json:"sharesUts,omitempty"`
|
||||||
|
|
||||||
PauseContainer *PauseContainerConfig `json:"pauseConfig"`
|
InfraContainer *InfraContainerConfig `json:"infraConfig"`
|
||||||
|
|
||||||
// Time pod was created
|
// Time pod was created
|
||||||
CreatedTime time.Time `json:"created"`
|
CreatedTime time.Time `json:"created"`
|
||||||
@ -65,9 +65,9 @@ type PodConfig struct {
|
|||||||
type podState struct {
|
type podState struct {
|
||||||
// CgroupPath is the path to the pod's CGroup
|
// CgroupPath is the path to the pod's CGroup
|
||||||
CgroupPath string `json:"cgroupPath"`
|
CgroupPath string `json:"cgroupPath"`
|
||||||
// PauseContainerID is the container that holds pod namespace information
|
// InfraContainerID is the container that holds pod namespace information
|
||||||
// Most often a pause container
|
// Most often an infra container
|
||||||
PauseContainerID string
|
InfraContainerID string
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodInspect represents the data we want to display for
|
// PodInspect represents the data we want to display for
|
||||||
@ -81,7 +81,7 @@ type PodInspect struct {
|
|||||||
// PodInspectState contains inspect data on the pod's state
|
// PodInspectState contains inspect data on the pod's state
|
||||||
type PodInspectState struct {
|
type PodInspectState struct {
|
||||||
CgroupPath string `json:"cgroupPath"`
|
CgroupPath string `json:"cgroupPath"`
|
||||||
PauseContainerID string `json:"pauseContainerID"`
|
InfraContainerID string `json:"infraContainerID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodContainerInfo keeps information on a container in a pod
|
// PodContainerInfo keeps information on a container in a pod
|
||||||
@ -90,9 +90,9 @@ type PodContainerInfo struct {
|
|||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PauseContainerConfig is the configuration for the pod's pause container
|
// InfraContainerConfig is the configuration for the pod's infra container
|
||||||
type PauseContainerConfig struct {
|
type InfraContainerConfig struct {
|
||||||
HasPauseContainer bool `json:"makePauseContainer"`
|
HasInfraContainer bool `json:"makeInfraContainer"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ID retrieves the pod's ID
|
// ID retrieves the pod's ID
|
||||||
@ -219,20 +219,20 @@ func (p *Pod) allContainers() ([]*Container, error) {
|
|||||||
return p.runtime.state.PodContainers(p)
|
return p.runtime.state.PodContainers(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasPauseContainer returns whether the pod will create a pause container
|
// HasInfraContainer returns whether the pod will create an infra container
|
||||||
func (p *Pod) HasPauseContainer() bool {
|
func (p *Pod) HasInfraContainer() bool {
|
||||||
return p.config.PauseContainer.HasPauseContainer
|
return p.config.InfraContainer.HasInfraContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
// SharesNamespaces checks if the pod has any kernel namespaces set as shared. A pause container will not be
|
// SharesNamespaces checks if the pod has any kernel namespaces set as shared. An infra container will not be
|
||||||
// created if no kernel namespaces are shared.
|
// created if no kernel namespaces are shared.
|
||||||
func (p *Pod) SharesNamespaces() bool {
|
func (p *Pod) SharesNamespaces() bool {
|
||||||
return p.SharesPID() || p.SharesIPC() || p.SharesNet() || p.SharesMNT() || p.SharesUser() || p.SharesUTS()
|
return p.SharesPID() || p.SharesIPC() || p.SharesNet() || p.SharesMNT() || p.SharesUser() || p.SharesUTS()
|
||||||
}
|
}
|
||||||
|
|
||||||
// PauseContainerID returns a the pause container ID for a pod.
|
// InfraContainerID returns the infra container ID for a pod.
|
||||||
// If the container returned is "", the pod has no pause container.
|
// If the container returned is "", the pod has no infra container.
|
||||||
func (p *Pod) PauseContainerID() (string, error) {
|
func (p *Pod) InfraContainerID() (string, error) {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ func (p *Pod) PauseContainerID() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.state.PauseContainerID, nil
|
return p.state.InfraContainerID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add pod batching
|
// TODO add pod batching
|
||||||
|
@ -426,7 +426,7 @@ func (p *Pod) Inspect() (*PodInspect, error) {
|
|||||||
}
|
}
|
||||||
podContainers = append(podContainers, pc)
|
podContainers = append(podContainers, pc)
|
||||||
}
|
}
|
||||||
pauseContainerID := p.state.PauseContainerID
|
infraContainerID := p.state.InfraContainerID
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &PodInspect{}, err
|
return &PodInspect{}, err
|
||||||
}
|
}
|
||||||
@ -437,7 +437,7 @@ func (p *Pod) Inspect() (*PodInspect, error) {
|
|||||||
Config: config,
|
Config: config,
|
||||||
State: &PodInspectState{
|
State: &PodInspectState{
|
||||||
CgroupPath: p.state.CgroupPath,
|
CgroupPath: p.state.CgroupPath,
|
||||||
PauseContainerID: pauseContainerID,
|
InfraContainerID: infraContainerID,
|
||||||
},
|
},
|
||||||
Containers: podContainers,
|
Containers: podContainers,
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// MarshalJSON marshal bytes to json - template
|
// MarshalJSON marshal bytes to json - template
|
||||||
func (j *PauseContainerConfig) MarshalJSON() ([]byte, error) {
|
func (j *InfraContainerConfig) MarshalJSON() ([]byte, error) {
|
||||||
var buf fflib.Buffer
|
var buf fflib.Buffer
|
||||||
if j == nil {
|
if j == nil {
|
||||||
buf.WriteString("null")
|
buf.WriteString("null")
|
||||||
@ -26,7 +26,7 @@ func (j *PauseContainerConfig) MarshalJSON() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSONBuf marshal buff to json - template
|
// MarshalJSONBuf marshal buff to json - template
|
||||||
func (j *PauseContainerConfig) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
|
func (j *InfraContainerConfig) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
|
||||||
if j == nil {
|
if j == nil {
|
||||||
buf.WriteString("null")
|
buf.WriteString("null")
|
||||||
return nil
|
return nil
|
||||||
@ -35,34 +35,34 @@ func (j *PauseContainerConfig) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
|
|||||||
var obj []byte
|
var obj []byte
|
||||||
_ = obj
|
_ = obj
|
||||||
_ = err
|
_ = err
|
||||||
if j.HasPauseContainer {
|
if j.HasInfraContainer {
|
||||||
buf.WriteString(`{"makePauseContainer":true`)
|
buf.WriteString(`{"makeInfraContainer":true`)
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(`{"makePauseContainer":false`)
|
buf.WriteString(`{"makeInfraContainer":false`)
|
||||||
}
|
}
|
||||||
buf.WriteByte('}')
|
buf.WriteByte('}')
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ffjtPauseContainerConfigbase = iota
|
ffjtInfraContainerConfigbase = iota
|
||||||
ffjtPauseContainerConfignosuchkey
|
ffjtInfraContainerConfignosuchkey
|
||||||
|
|
||||||
ffjtPauseContainerConfigHasPauseContainer
|
ffjtInfraContainerConfigHasInfraContainer
|
||||||
)
|
)
|
||||||
|
|
||||||
var ffjKeyPauseContainerConfigHasPauseContainer = []byte("makePauseContainer")
|
var ffjKeyInfraContainerConfigHasInfraContainer = []byte("makeInfraContainer")
|
||||||
|
|
||||||
// UnmarshalJSON umarshall json - template of ffjson
|
// UnmarshalJSON umarshall json - template of ffjson
|
||||||
func (j *PauseContainerConfig) UnmarshalJSON(input []byte) error {
|
func (j *InfraContainerConfig) UnmarshalJSON(input []byte) error {
|
||||||
fs := fflib.NewFFLexer(input)
|
fs := fflib.NewFFLexer(input)
|
||||||
return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
|
return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSONFFLexer fast json unmarshall - template ffjson
|
// UnmarshalJSONFFLexer fast json unmarshall - template ffjson
|
||||||
func (j *PauseContainerConfig) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error {
|
func (j *InfraContainerConfig) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error {
|
||||||
var err error
|
var err error
|
||||||
currentKey := ffjtPauseContainerConfigbase
|
currentKey := ffjtInfraContainerConfigbase
|
||||||
_ = currentKey
|
_ = currentKey
|
||||||
tok := fflib.FFTok_init
|
tok := fflib.FFTok_init
|
||||||
wantedTok := fflib.FFTok_init
|
wantedTok := fflib.FFTok_init
|
||||||
@ -108,7 +108,7 @@ mainparse:
|
|||||||
kn := fs.Output.Bytes()
|
kn := fs.Output.Bytes()
|
||||||
if len(kn) <= 0 {
|
if len(kn) <= 0 {
|
||||||
// "" case. hrm.
|
// "" case. hrm.
|
||||||
currentKey = ffjtPauseContainerConfignosuchkey
|
currentKey = ffjtInfraContainerConfignosuchkey
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
} else {
|
} else {
|
||||||
@ -116,21 +116,21 @@ mainparse:
|
|||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
|
|
||||||
if bytes.Equal(ffjKeyPauseContainerConfigHasPauseContainer, kn) {
|
if bytes.Equal(ffjKeyInfraContainerConfigHasInfraContainer, kn) {
|
||||||
currentKey = ffjtPauseContainerConfigHasPauseContainer
|
currentKey = ffjtInfraContainerConfigHasInfraContainer
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if fflib.EqualFoldRight(ffjKeyPauseContainerConfigHasPauseContainer, kn) {
|
if fflib.EqualFoldRight(ffjKeyInfraContainerConfigHasInfraContainer, kn) {
|
||||||
currentKey = ffjtPauseContainerConfigHasPauseContainer
|
currentKey = ffjtInfraContainerConfigHasInfraContainer
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
|
|
||||||
currentKey = ffjtPauseContainerConfignosuchkey
|
currentKey = ffjtInfraContainerConfignosuchkey
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
@ -147,10 +147,10 @@ mainparse:
|
|||||||
if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null {
|
if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null {
|
||||||
switch currentKey {
|
switch currentKey {
|
||||||
|
|
||||||
case ffjtPauseContainerConfigHasPauseContainer:
|
case ffjtInfraContainerConfigHasInfraContainer:
|
||||||
goto handle_HasPauseContainer
|
goto handle_HasInfraContainer
|
||||||
|
|
||||||
case ffjtPauseContainerConfignosuchkey:
|
case ffjtInfraContainerConfignosuchkey:
|
||||||
err = fs.SkipField(tok)
|
err = fs.SkipField(tok)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fs.WrapErr(err)
|
return fs.WrapErr(err)
|
||||||
@ -164,9 +164,9 @@ mainparse:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_HasPauseContainer:
|
handle_HasInfraContainer:
|
||||||
|
|
||||||
/* handler: j.HasPauseContainer type=bool kind=bool quoted=false*/
|
/* handler: j.HasInfraContainer type=bool kind=bool quoted=false*/
|
||||||
|
|
||||||
{
|
{
|
||||||
if tok != fflib.FFTok_bool && tok != fflib.FFTok_null {
|
if tok != fflib.FFTok_bool && tok != fflib.FFTok_null {
|
||||||
@ -182,11 +182,11 @@ handle_HasPauseContainer:
|
|||||||
|
|
||||||
if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 {
|
if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 {
|
||||||
|
|
||||||
j.HasPauseContainer = true
|
j.HasInfraContainer = true
|
||||||
|
|
||||||
} else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
|
} else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 {
|
||||||
|
|
||||||
j.HasPauseContainer = false
|
j.HasInfraContainer = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
err = errors.New("unexpected bytes for true/false value")
|
err = errors.New("unexpected bytes for true/false value")
|
||||||
@ -323,19 +323,19 @@ func (j *PodConfig) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
|
|||||||
}
|
}
|
||||||
buf.WriteByte(',')
|
buf.WriteByte(',')
|
||||||
}
|
}
|
||||||
if j.PauseContainer != nil {
|
if j.InfraContainer != nil {
|
||||||
buf.WriteString(`"pauseConfig":`)
|
buf.WriteString(`"infraConfig":`)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
err = j.PauseContainer.MarshalJSONBuf(buf)
|
err = j.InfraContainer.MarshalJSONBuf(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(`"pauseConfig":null`)
|
buf.WriteString(`"infraConfig":null`)
|
||||||
}
|
}
|
||||||
buf.WriteString(`,"created":`)
|
buf.WriteString(`,"created":`)
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ const (
|
|||||||
|
|
||||||
ffjtPodConfigUsePodUTS
|
ffjtPodConfigUsePodUTS
|
||||||
|
|
||||||
ffjtPodConfigPauseContainer
|
ffjtPodConfigInfraContainer
|
||||||
|
|
||||||
ffjtPodConfigCreatedTime
|
ffjtPodConfigCreatedTime
|
||||||
)
|
)
|
||||||
@ -409,7 +409,7 @@ var ffjKeyPodConfigUsePodUser = []byte("sharesUser")
|
|||||||
|
|
||||||
var ffjKeyPodConfigUsePodUTS = []byte("sharesUts")
|
var ffjKeyPodConfigUsePodUTS = []byte("sharesUts")
|
||||||
|
|
||||||
var ffjKeyPodConfigPauseContainer = []byte("pauseConfig")
|
var ffjKeyPodConfigInfraContainer = []byte("infraConfig")
|
||||||
|
|
||||||
var ffjKeyPodConfigCreatedTime = []byte("created")
|
var ffjKeyPodConfigCreatedTime = []byte("created")
|
||||||
|
|
||||||
@ -493,6 +493,11 @@ mainparse:
|
|||||||
currentKey = ffjtPodConfigID
|
currentKey = ffjtPodConfigID
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
|
|
||||||
|
} else if bytes.Equal(ffjKeyPodConfigInfraContainer, kn) {
|
||||||
|
currentKey = ffjtPodConfigInfraContainer
|
||||||
|
state = fflib.FFParse_want_colon
|
||||||
|
goto mainparse
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
@ -516,14 +521,6 @@ mainparse:
|
|||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'p':
|
|
||||||
|
|
||||||
if bytes.Equal(ffjKeyPodConfigPauseContainer, kn) {
|
|
||||||
currentKey = ffjtPodConfigPauseContainer
|
|
||||||
state = fflib.FFParse_want_colon
|
|
||||||
goto mainparse
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
|
|
||||||
if bytes.Equal(ffjKeyPodConfigUsePodCgroup, kn) {
|
if bytes.Equal(ffjKeyPodConfigUsePodCgroup, kn) {
|
||||||
@ -570,8 +567,8 @@ mainparse:
|
|||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
|
|
||||||
if fflib.EqualFoldRight(ffjKeyPodConfigPauseContainer, kn) {
|
if fflib.SimpleLetterEqualFold(ffjKeyPodConfigInfraContainer, kn) {
|
||||||
currentKey = ffjtPodConfigPauseContainer
|
currentKey = ffjtPodConfigInfraContainer
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
@ -701,8 +698,8 @@ mainparse:
|
|||||||
case ffjtPodConfigUsePodUTS:
|
case ffjtPodConfigUsePodUTS:
|
||||||
goto handle_UsePodUTS
|
goto handle_UsePodUTS
|
||||||
|
|
||||||
case ffjtPodConfigPauseContainer:
|
case ffjtPodConfigInfraContainer:
|
||||||
goto handle_PauseContainer
|
goto handle_InfraContainer
|
||||||
|
|
||||||
case ffjtPodConfigCreatedTime:
|
case ffjtPodConfigCreatedTime:
|
||||||
goto handle_CreatedTime
|
goto handle_CreatedTime
|
||||||
@ -1175,22 +1172,22 @@ handle_UsePodUTS:
|
|||||||
state = fflib.FFParse_after_value
|
state = fflib.FFParse_after_value
|
||||||
goto mainparse
|
goto mainparse
|
||||||
|
|
||||||
handle_PauseContainer:
|
handle_InfraContainer:
|
||||||
|
|
||||||
/* handler: j.PauseContainer type=libpod.PauseContainerConfig kind=struct quoted=false*/
|
/* handler: j.InfraContainer type=libpod.InfraContainerConfig kind=struct quoted=false*/
|
||||||
|
|
||||||
{
|
{
|
||||||
if tok == fflib.FFTok_null {
|
if tok == fflib.FFTok_null {
|
||||||
|
|
||||||
j.PauseContainer = nil
|
j.InfraContainer = nil
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if j.PauseContainer == nil {
|
if j.InfraContainer == nil {
|
||||||
j.PauseContainer = new(PauseContainerConfig)
|
j.InfraContainer = new(InfraContainerConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = j.PauseContainer.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key)
|
err = j.InfraContainer.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -2223,8 +2220,8 @@ func (j *PodInspectState) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
|
|||||||
_ = err
|
_ = err
|
||||||
buf.WriteString(`{"cgroupPath":`)
|
buf.WriteString(`{"cgroupPath":`)
|
||||||
fflib.WriteJsonString(buf, string(j.CgroupPath))
|
fflib.WriteJsonString(buf, string(j.CgroupPath))
|
||||||
buf.WriteString(`,"pauseContainerID":`)
|
buf.WriteString(`,"infraContainerID":`)
|
||||||
fflib.WriteJsonString(buf, string(j.PauseContainerID))
|
fflib.WriteJsonString(buf, string(j.InfraContainerID))
|
||||||
buf.WriteByte('}')
|
buf.WriteByte('}')
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -2235,12 +2232,12 @@ const (
|
|||||||
|
|
||||||
ffjtPodInspectStateCgroupPath
|
ffjtPodInspectStateCgroupPath
|
||||||
|
|
||||||
ffjtPodInspectStatePauseContainerID
|
ffjtPodInspectStateInfraContainerID
|
||||||
)
|
)
|
||||||
|
|
||||||
var ffjKeyPodInspectStateCgroupPath = []byte("cgroupPath")
|
var ffjKeyPodInspectStateCgroupPath = []byte("cgroupPath")
|
||||||
|
|
||||||
var ffjKeyPodInspectStatePauseContainerID = []byte("pauseContainerID")
|
var ffjKeyPodInspectStateInfraContainerID = []byte("infraContainerID")
|
||||||
|
|
||||||
// UnmarshalJSON umarshall json - template of ffjson
|
// UnmarshalJSON umarshall json - template of ffjson
|
||||||
func (j *PodInspectState) UnmarshalJSON(input []byte) error {
|
func (j *PodInspectState) UnmarshalJSON(input []byte) error {
|
||||||
@ -2311,18 +2308,18 @@ mainparse:
|
|||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'p':
|
case 'i':
|
||||||
|
|
||||||
if bytes.Equal(ffjKeyPodInspectStatePauseContainerID, kn) {
|
if bytes.Equal(ffjKeyPodInspectStateInfraContainerID, kn) {
|
||||||
currentKey = ffjtPodInspectStatePauseContainerID
|
currentKey = ffjtPodInspectStateInfraContainerID
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if fflib.EqualFoldRight(ffjKeyPodInspectStatePauseContainerID, kn) {
|
if fflib.SimpleLetterEqualFold(ffjKeyPodInspectStateInfraContainerID, kn) {
|
||||||
currentKey = ffjtPodInspectStatePauseContainerID
|
currentKey = ffjtPodInspectStateInfraContainerID
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
@ -2353,8 +2350,8 @@ mainparse:
|
|||||||
case ffjtPodInspectStateCgroupPath:
|
case ffjtPodInspectStateCgroupPath:
|
||||||
goto handle_CgroupPath
|
goto handle_CgroupPath
|
||||||
|
|
||||||
case ffjtPodInspectStatePauseContainerID:
|
case ffjtPodInspectStateInfraContainerID:
|
||||||
goto handle_PauseContainerID
|
goto handle_InfraContainerID
|
||||||
|
|
||||||
case ffjtPodInspectStatenosuchkey:
|
case ffjtPodInspectStatenosuchkey:
|
||||||
err = fs.SkipField(tok)
|
err = fs.SkipField(tok)
|
||||||
@ -2396,9 +2393,9 @@ handle_CgroupPath:
|
|||||||
state = fflib.FFParse_after_value
|
state = fflib.FFParse_after_value
|
||||||
goto mainparse
|
goto mainparse
|
||||||
|
|
||||||
handle_PauseContainerID:
|
handle_InfraContainerID:
|
||||||
|
|
||||||
/* handler: j.PauseContainerID type=string kind=string quoted=false*/
|
/* handler: j.InfraContainerID type=string kind=string quoted=false*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -2414,7 +2411,7 @@ handle_PauseContainerID:
|
|||||||
|
|
||||||
outBuf := fs.Output.Bytes()
|
outBuf := fs.Output.Bytes()
|
||||||
|
|
||||||
j.PauseContainerID = string(string(outBuf))
|
j.InfraContainerID = string(string(outBuf))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2466,8 +2463,8 @@ func (j *podState) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
|
|||||||
_ = err
|
_ = err
|
||||||
buf.WriteString(`{"cgroupPath":`)
|
buf.WriteString(`{"cgroupPath":`)
|
||||||
fflib.WriteJsonString(buf, string(j.CgroupPath))
|
fflib.WriteJsonString(buf, string(j.CgroupPath))
|
||||||
buf.WriteString(`,"PauseContainerID":`)
|
buf.WriteString(`,"InfraContainerID":`)
|
||||||
fflib.WriteJsonString(buf, string(j.PauseContainerID))
|
fflib.WriteJsonString(buf, string(j.InfraContainerID))
|
||||||
buf.WriteByte('}')
|
buf.WriteByte('}')
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -2478,12 +2475,12 @@ const (
|
|||||||
|
|
||||||
ffjtpodStateCgroupPath
|
ffjtpodStateCgroupPath
|
||||||
|
|
||||||
ffjtpodStatePauseContainerID
|
ffjtpodStateInfraContainerID
|
||||||
)
|
)
|
||||||
|
|
||||||
var ffjKeypodStateCgroupPath = []byte("cgroupPath")
|
var ffjKeypodStateCgroupPath = []byte("cgroupPath")
|
||||||
|
|
||||||
var ffjKeypodStatePauseContainerID = []byte("PauseContainerID")
|
var ffjKeypodStateInfraContainerID = []byte("InfraContainerID")
|
||||||
|
|
||||||
// UnmarshalJSON umarshall json - template of ffjson
|
// UnmarshalJSON umarshall json - template of ffjson
|
||||||
func (j *podState) UnmarshalJSON(input []byte) error {
|
func (j *podState) UnmarshalJSON(input []byte) error {
|
||||||
@ -2546,10 +2543,10 @@ mainparse:
|
|||||||
} else {
|
} else {
|
||||||
switch kn[0] {
|
switch kn[0] {
|
||||||
|
|
||||||
case 'P':
|
case 'I':
|
||||||
|
|
||||||
if bytes.Equal(ffjKeypodStatePauseContainerID, kn) {
|
if bytes.Equal(ffjKeypodStateInfraContainerID, kn) {
|
||||||
currentKey = ffjtpodStatePauseContainerID
|
currentKey = ffjtpodStateInfraContainerID
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
@ -2564,8 +2561,8 @@ mainparse:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if fflib.EqualFoldRight(ffjKeypodStatePauseContainerID, kn) {
|
if fflib.SimpleLetterEqualFold(ffjKeypodStateInfraContainerID, kn) {
|
||||||
currentKey = ffjtpodStatePauseContainerID
|
currentKey = ffjtpodStateInfraContainerID
|
||||||
state = fflib.FFParse_want_colon
|
state = fflib.FFParse_want_colon
|
||||||
goto mainparse
|
goto mainparse
|
||||||
}
|
}
|
||||||
@ -2596,8 +2593,8 @@ mainparse:
|
|||||||
case ffjtpodStateCgroupPath:
|
case ffjtpodStateCgroupPath:
|
||||||
goto handle_CgroupPath
|
goto handle_CgroupPath
|
||||||
|
|
||||||
case ffjtpodStatePauseContainerID:
|
case ffjtpodStateInfraContainerID:
|
||||||
goto handle_PauseContainerID
|
goto handle_InfraContainerID
|
||||||
|
|
||||||
case ffjtpodStatenosuchkey:
|
case ffjtpodStatenosuchkey:
|
||||||
err = fs.SkipField(tok)
|
err = fs.SkipField(tok)
|
||||||
@ -2639,9 +2636,9 @@ handle_CgroupPath:
|
|||||||
state = fflib.FFParse_after_value
|
state = fflib.FFParse_after_value
|
||||||
goto mainparse
|
goto mainparse
|
||||||
|
|
||||||
handle_PauseContainerID:
|
handle_InfraContainerID:
|
||||||
|
|
||||||
/* handler: j.PauseContainerID type=string kind=string quoted=false*/
|
/* handler: j.InfraContainerID type=string kind=string quoted=false*/
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -2657,7 +2654,7 @@ handle_PauseContainerID:
|
|||||||
|
|
||||||
outBuf := fs.Output.Bytes()
|
outBuf := fs.Output.Bytes()
|
||||||
|
|
||||||
j.PauseContainerID = string(string(outBuf))
|
j.InfraContainerID = string(string(outBuf))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ func newPod(lockDir string, runtime *Runtime) (*Pod, error) {
|
|||||||
pod.config.ID = stringid.GenerateNonCryptoID()
|
pod.config.ID = stringid.GenerateNonCryptoID()
|
||||||
pod.config.Labels = make(map[string]string)
|
pod.config.Labels = make(map[string]string)
|
||||||
pod.config.CreatedTime = time.Now()
|
pod.config.CreatedTime = time.Now()
|
||||||
pod.config.PauseContainer = new(PauseContainerConfig)
|
pod.config.InfraContainer = new(InfraContainerConfig)
|
||||||
pod.state = new(podState)
|
pod.state = new(podState)
|
||||||
pod.runtime = runtime
|
pod.runtime = runtime
|
||||||
|
|
||||||
|
@ -57,10 +57,10 @@ const (
|
|||||||
// place of the configuration file pointed to by ConfigPath.
|
// place of the configuration file pointed to by ConfigPath.
|
||||||
OverrideConfigPath = "/etc/containers/libpod.conf"
|
OverrideConfigPath = "/etc/containers/libpod.conf"
|
||||||
|
|
||||||
// DefaultPauseImage to use for pause container
|
// DefaultInfraImage to use for infra container
|
||||||
DefaultPauseImage = "k8s.gcr.io/pause:3.1"
|
DefaultInfraImage = "k8s.gcr.io/pause:3.1"
|
||||||
// DefaultPauseCommand to be run in a pause container
|
// DefaultInfraCommand to be run in an infra container
|
||||||
DefaultPauseCommand = "/pause"
|
DefaultInfraCommand = "/pause"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A RuntimeOption is a functional option which alters the Runtime created by
|
// A RuntimeOption is a functional option which alters the Runtime created by
|
||||||
@ -157,10 +157,10 @@ type RuntimeConfig struct {
|
|||||||
// and all containers and pods will be visible.
|
// and all containers and pods will be visible.
|
||||||
// The default namespace is "".
|
// The default namespace is "".
|
||||||
Namespace string `toml:"namespace,omitempty"`
|
Namespace string `toml:"namespace,omitempty"`
|
||||||
// PauseImage is the image a pod pause container will use to manage namespaces
|
// InfraImage is the image a pod infra container will use to manage namespaces
|
||||||
PauseImage string `toml:"pause_image"`
|
InfraImage string `toml:"infra_image"`
|
||||||
// PauseCommand is the command run to start up a pod pause container
|
// InfraCommand is the command run to start up a pod infra container
|
||||||
PauseCommand string `toml:"pause_command"`
|
InfraCommand string `toml:"infra_command"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -195,8 +195,8 @@ var (
|
|||||||
NoPivotRoot: false,
|
NoPivotRoot: false,
|
||||||
CNIConfigDir: "/etc/cni/net.d/",
|
CNIConfigDir: "/etc/cni/net.d/",
|
||||||
CNIPluginDir: []string{"/usr/libexec/cni", "/usr/lib/cni", "/opt/cni/bin"},
|
CNIPluginDir: []string{"/usr/libexec/cni", "/usr/lib/cni", "/opt/cni/bin"},
|
||||||
PauseCommand: DefaultPauseCommand,
|
InfraCommand: DefaultInfraCommand,
|
||||||
PauseImage: DefaultPauseImage,
|
InfraImage: DefaultInfraImage,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -228,9 +228,9 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
pauseID := pod.state.PauseContainerID
|
infraID := pod.state.InfraContainerID
|
||||||
if c.ID() == pauseID {
|
if c.ID() == infraID {
|
||||||
return errors.Errorf("a pause container cannot be removed without removing pod %s", pod.ID())
|
return errors.Errorf("an infra container cannot be removed without removing pod %s", pod.ID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,40 +11,40 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// IDTruncLength is the length of the pod's id that will be used to make the
|
// IDTruncLength is the length of the pod's id that will be used to make the
|
||||||
// pause container name
|
// infra container name
|
||||||
IDTruncLength = 12
|
IDTruncLength = 12
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Runtime) makePauseContainer(ctx context.Context, p *Pod, imgName, imgID string) (*Container, error) {
|
func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, imgID string) (*Container, error) {
|
||||||
|
|
||||||
// Set up generator for pause container defaults
|
// Set up generator for infra container defaults
|
||||||
g, err := generate.New("linux")
|
g, err := generate.New("linux")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
g.SetRootReadonly(true)
|
g.SetRootReadonly(true)
|
||||||
g.SetProcessArgs([]string{r.config.PauseCommand})
|
g.SetProcessArgs([]string{r.config.InfraCommand})
|
||||||
|
|
||||||
containerName := p.ID()[:IDTruncLength] + "-infra"
|
containerName := p.ID()[:IDTruncLength] + "-infra"
|
||||||
var options []CtrCreateOption
|
var options []CtrCreateOption
|
||||||
options = append(options, r.WithPod(p))
|
options = append(options, r.WithPod(p))
|
||||||
options = append(options, WithRootFSFromImage(imgID, imgName, false))
|
options = append(options, WithRootFSFromImage(imgID, imgName, false))
|
||||||
options = append(options, WithName(containerName))
|
options = append(options, WithName(containerName))
|
||||||
options = append(options, withIsPause())
|
options = append(options, withIsInfra())
|
||||||
|
|
||||||
return r.newContainer(ctx, g.Config, options...)
|
return r.newContainer(ctx, g.Config, options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// createPauseContainer wrap creates a pause container for a pod.
|
// createInfraContainer wrap creates an infra container for a pod.
|
||||||
// A pause container becomes the basis for kernel namespace sharing between
|
// An infra container becomes the basis for kernel namespace sharing between
|
||||||
// containers in the pod.
|
// containers in the pod.
|
||||||
func (r *Runtime) createPauseContainer(ctx context.Context, p *Pod) (*Container, error) {
|
func (r *Runtime) createInfraContainer(ctx context.Context, p *Pod) (*Container, error) {
|
||||||
if !r.valid {
|
if !r.valid {
|
||||||
return nil, ErrRuntimeStopped
|
return nil, ErrRuntimeStopped
|
||||||
}
|
}
|
||||||
|
|
||||||
newImage, err := r.ImageRuntime().New(ctx, r.config.PauseImage, "", "", nil, nil, image.SigningOptions{}, false, false)
|
newImage, err := r.ImageRuntime().New(ctx, r.config.InfraImage, "", "", nil, nil, image.SigningOptions{}, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -56,5 +56,5 @@ func (r *Runtime) createPauseContainer(ctx context.Context, p *Pod) (*Container,
|
|||||||
imageName := newImage.Names()[0]
|
imageName := newImage.Names()[0]
|
||||||
imageID := data.ID
|
imageID := data.ID
|
||||||
|
|
||||||
return r.makePauseContainer(ctx, p, imageName, imageID)
|
return r.makeInfraContainer(ctx, p, imageName, imageID)
|
||||||
}
|
}
|
@ -87,25 +87,25 @@ func (r *Runtime) NewPod(ctx context.Context, options ...PodCreateOption) (*Pod,
|
|||||||
if pod.config.UsePodCgroup {
|
if pod.config.UsePodCgroup {
|
||||||
logrus.Debugf("Got pod cgroup as %s", pod.state.CgroupPath)
|
logrus.Debugf("Got pod cgroup as %s", pod.state.CgroupPath)
|
||||||
}
|
}
|
||||||
if pod.HasPauseContainer() != pod.SharesNamespaces() {
|
if pod.HasInfraContainer() != pod.SharesNamespaces() {
|
||||||
return nil, errors.Errorf("Pods must have a pause container to share namespaces")
|
return nil, errors.Errorf("Pods must have an infra container to share namespaces")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.state.AddPod(pod); err != nil {
|
if err := r.state.AddPod(pod); err != nil {
|
||||||
return nil, errors.Wrapf(err, "error adding pod to state")
|
return nil, errors.Wrapf(err, "error adding pod to state")
|
||||||
}
|
}
|
||||||
|
|
||||||
if pod.HasPauseContainer() {
|
if pod.HasInfraContainer() {
|
||||||
ctr, err := r.createPauseContainer(ctx, pod)
|
ctr, err := r.createInfraContainer(ctx, pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Tear down pod, as it is assumed a the pod will contain
|
// Tear down pod, as it is assumed a the pod will contain
|
||||||
// a pause container, and it does not.
|
// a pause container, and it does not.
|
||||||
if err2 := r.removePod(ctx, pod, true, true); err2 != nil {
|
if err2 := r.removePod(ctx, pod, true, true); err2 != nil {
|
||||||
logrus.Errorf("Error removing pod after pause container creation failure: %v", err2)
|
logrus.Errorf("Error removing pod after pause container creation failure: %v", err2)
|
||||||
}
|
}
|
||||||
return nil, errors.Wrapf(err, "error adding Pause Container")
|
return nil, errors.Wrapf(err, "error adding Infra Container")
|
||||||
}
|
}
|
||||||
pod.state.PauseContainerID = ctr.ID()
|
pod.state.InfraContainerID = ctr.ID()
|
||||||
if err := pod.save(); err != nil {
|
if err := pod.save(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool)
|
|||||||
if err := p.updatePod(); err != nil {
|
if err := p.updatePod(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pauseCtrID := p.state.PauseContainerID
|
pauseCtrID := p.state.InfraContainerID
|
||||||
if numCtrs == 1 && ctrs[0].ID() == pauseCtrID {
|
if numCtrs == 1 && ctrs[0].ID() == pauseCtrID {
|
||||||
removeCtrs = true
|
removeCtrs = true
|
||||||
force = true
|
force = true
|
||||||
|
@ -170,7 +170,7 @@ type ContainerInspectData struct {
|
|||||||
NetworkSettings *NetworkSettings `json:"NetworkSettings"` //TODO
|
NetworkSettings *NetworkSettings `json:"NetworkSettings"` //TODO
|
||||||
ExitCommand []string `json:"ExitCommand"`
|
ExitCommand []string `json:"ExitCommand"`
|
||||||
Namespace string `json:"Namespace"`
|
Namespace string `json:"Namespace"`
|
||||||
IsPause bool `json:"IsPause"`
|
IsInfra bool `json:"IsInfra"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerInspectState represents the state of a container.
|
// ContainerInspectState represents the state of a container.
|
||||||
|
@ -21,14 +21,14 @@ func (i *LibpodAPI) CreatePod(call iopodman.VarlinkCall, create iopodman.PodCrea
|
|||||||
if create.Name != "" {
|
if create.Name != "" {
|
||||||
options = append(options, libpod.WithPodName(create.Name))
|
options = append(options, libpod.WithPodName(create.Name))
|
||||||
}
|
}
|
||||||
if len(create.Share) > 0 && !create.Pause {
|
if len(create.Share) > 0 && !create.Infra {
|
||||||
return call.ReplyErrorOccurred("You cannot share kernel namespaces on the pod level without a pause container")
|
return call.ReplyErrorOccurred("You cannot share kernel namespaces on the pod level without an infra container")
|
||||||
}
|
}
|
||||||
if len(create.Share) == 0 && create.Pause {
|
if len(create.Share) == 0 && create.Infra {
|
||||||
return call.ReplyErrorOccurred("You must share kernel namespaces to run a pause container")
|
return call.ReplyErrorOccurred("You must share kernel namespaces to run an infra container")
|
||||||
}
|
}
|
||||||
if create.Pause {
|
if create.Infra {
|
||||||
options = append(options, libpod.WithPauseContainer())
|
options = append(options, libpod.WithInfraContainer())
|
||||||
nsOptions, err := shared.GetNamespaceOptions(create.Share)
|
nsOptions, err := shared.GetNamespaceOptions(create.Share)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -32,7 +32,7 @@ var (
|
|||||||
CGROUP_MANAGER = "systemd"
|
CGROUP_MANAGER = "systemd"
|
||||||
STORAGE_OPTIONS = "--storage-driver vfs"
|
STORAGE_OPTIONS = "--storage-driver vfs"
|
||||||
ARTIFACT_DIR = "/tmp/.artifacts"
|
ARTIFACT_DIR = "/tmp/.artifacts"
|
||||||
CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, pause}
|
CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra}
|
||||||
RESTORE_IMAGES = []string{ALPINE, BB}
|
RESTORE_IMAGES = []string{ALPINE, BB}
|
||||||
ALPINE = "docker.io/library/alpine:latest"
|
ALPINE = "docker.io/library/alpine:latest"
|
||||||
BB = "docker.io/library/busybox:latest"
|
BB = "docker.io/library/busybox:latest"
|
||||||
@ -41,7 +41,7 @@ var (
|
|||||||
nginx = "quay.io/baude/alpine_nginx:latest"
|
nginx = "quay.io/baude/alpine_nginx:latest"
|
||||||
redis = "docker.io/library/redis:alpine"
|
redis = "docker.io/library/redis:alpine"
|
||||||
registry = "docker.io/library/registry:2"
|
registry = "docker.io/library/registry:2"
|
||||||
pause = "k8s.gcr.io/pause:3.1"
|
infra = "k8s.gcr.io/pause:3.1"
|
||||||
defaultWaitTimeout = 90
|
defaultWaitTimeout = 90
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -423,10 +423,10 @@ func (p *PodmanTest) RestoreAllArtifacts() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatePod creates a pod with no pause container
|
// CreatePod creates a pod with no infra container
|
||||||
// it optionally takes a pod name
|
// it optionally takes a pod name
|
||||||
func (p *PodmanTest) CreatePod(name string) (*PodmanSession, int, string) {
|
func (p *PodmanTest) CreatePod(name string) (*PodmanSession, int, string) {
|
||||||
var podmanArgs = []string{"pod", "create", "--pause=false", "--share", ""}
|
var podmanArgs = []string{"pod", "create", "--infra=false", "--share", ""}
|
||||||
if name != "" {
|
if name != "" {
|
||||||
podmanArgs = append(podmanArgs, "--name", name)
|
podmanArgs = append(podmanArgs, "--name", name)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ var _ = Describe("Podman pod create", func() {
|
|||||||
}
|
}
|
||||||
podmanTest = PodmanCreate(tempdir)
|
podmanTest = PodmanCreate(tempdir)
|
||||||
podmanTest.RestoreAllArtifacts()
|
podmanTest.RestoreAllArtifacts()
|
||||||
podmanTest.RestoreArtifact(pause)
|
podmanTest.RestoreArtifact(infra)
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
@ -33,7 +33,7 @@ var _ = Describe("Podman pod create", func() {
|
|||||||
GinkgoWriter.Write([]byte(timedResult))
|
GinkgoWriter.Write([]byte(timedResult))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman create pause container", func() {
|
It("podman create infra container", func() {
|
||||||
session := podmanTest.Podman([]string{"pod", "create"})
|
session := podmanTest.Podman([]string{"pod", "create"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
@ -50,7 +50,7 @@ var _ = Describe("Podman pod create", func() {
|
|||||||
Expect(len(check.OutputToStringArray())).To(Equal(1))
|
Expect(len(check.OutputToStringArray())).To(Equal(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman start pause container", func() {
|
It("podman start infra container", func() {
|
||||||
session := podmanTest.Podman([]string{"pod", "create"})
|
session := podmanTest.Podman([]string{"pod", "create"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
@ -66,7 +66,7 @@ var _ = Describe("Podman pod create", func() {
|
|||||||
Expect(len(check.OutputToStringArray())).To(Equal(1))
|
Expect(len(check.OutputToStringArray())).To(Equal(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman pause container namespaces", func() {
|
It("podman infra container namespaces", func() {
|
||||||
session := podmanTest.Podman([]string{"pod", "create"})
|
session := podmanTest.Podman([]string{"pod", "create"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
@ -134,8 +134,8 @@ var _ = Describe("Podman pod create", func() {
|
|||||||
Expect(len(PIDs)).To(Equal(4))
|
Expect(len(PIDs)).To(Equal(4))
|
||||||
|
|
||||||
ctrPID, _ := strconv.Atoi(PIDs[1])
|
ctrPID, _ := strconv.Atoi(PIDs[1])
|
||||||
pausePID, _ := strconv.Atoi(PIDs[2])
|
infraPID, _ := strconv.Atoi(PIDs[2])
|
||||||
Expect(ctrPID).To(BeNumerically("<", pausePID))
|
Expect(ctrPID).To(BeNumerically("<", infraPID))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman pod doesn't share PIDNS if requested to not", func() {
|
It("podman pod doesn't share PIDNS if requested to not", func() {
|
||||||
@ -160,11 +160,11 @@ var _ = Describe("Podman pod create", func() {
|
|||||||
check = podmanTest.Podman([]string{"top", podID[:12] + "-infra", "pid"})
|
check = podmanTest.Podman([]string{"top", podID[:12] + "-infra", "pid"})
|
||||||
check.WaitWithDefaultTimeout()
|
check.WaitWithDefaultTimeout()
|
||||||
Expect(check.ExitCode()).To(Equal(0))
|
Expect(check.ExitCode()).To(Equal(0))
|
||||||
pauseTop := check.OutputToStringArray()
|
infraTop := check.OutputToStringArray()
|
||||||
|
|
||||||
ctrPID, _ := strconv.Atoi(ctrTop[1])
|
ctrPID, _ := strconv.Atoi(ctrTop[1])
|
||||||
pausePID, _ := strconv.Atoi(pauseTop[1])
|
infraPID, _ := strconv.Atoi(infraTop[1])
|
||||||
Expect(ctrPID).To(Equal(pausePID))
|
Expect(ctrPID).To(Equal(infraPID))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman pod container can override pod net NS", func() {
|
It("podman pod container can override pod net NS", func() {
|
||||||
@ -263,7 +263,7 @@ var _ = Describe("Podman pod create", func() {
|
|||||||
Expect(PID1).To(Not(Equal(PID2)))
|
Expect(PID1).To(Not(Equal(PID2)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman pod pause container deletion", func() {
|
It("podman pod infra container deletion", func() {
|
||||||
session := podmanTest.Podman([]string{"pod", "create", "--share", "ipc"})
|
session := podmanTest.Podman([]string{"pod", "create", "--share", "ipc"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
@ -272,9 +272,9 @@ var _ = Describe("Podman pod create", func() {
|
|||||||
session = podmanTest.Podman([]string{"ps", "-aq"})
|
session = podmanTest.Podman([]string{"ps", "-aq"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
pauseID := session.OutputToString()
|
infraID := session.OutputToString()
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"rm", pauseID})
|
session = podmanTest.Podman([]string{"rm", infraID})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Not(Equal(0)))
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
||||||
|
|
@ -43,12 +43,10 @@ var _ = Describe("Podman pod stats", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman stats on a specific running pod", func() {
|
It("podman stats on a specific running pod", func() {
|
||||||
session := podmanTest.Podman([]string{"pod", "create"})
|
_, ec, podid := podmanTest.CreatePod("")
|
||||||
session.WaitWithDefaultTimeout()
|
Expect(ec).To(Equal(0))
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
|
||||||
podid := session.OutputToString()
|
|
||||||
|
|
||||||
session = podmanTest.RunTopContainerInPod("", podid)
|
session := podmanTest.RunTopContainerInPod("", podid)
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
@ -100,12 +98,10 @@ var _ = Describe("Podman pod stats", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman stats on running pods", func() {
|
It("podman stats on running pods", func() {
|
||||||
session := podmanTest.Podman([]string{"pod", "create"})
|
_, ec, podid := podmanTest.CreatePod("")
|
||||||
session.WaitWithDefaultTimeout()
|
Expect(ec).To(Equal(0))
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
|
||||||
podid := session.OutputToString()
|
|
||||||
|
|
||||||
session = podmanTest.RunTopContainerInPod("", podid)
|
session := podmanTest.RunTopContainerInPod("", podid)
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
@ -119,12 +115,10 @@ var _ = Describe("Podman pod stats", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman stats on all pods", func() {
|
It("podman stats on all pods", func() {
|
||||||
session := podmanTest.Podman([]string{"pod", "create"})
|
_, ec, podid := podmanTest.CreatePod("")
|
||||||
session.WaitWithDefaultTimeout()
|
Expect(ec).To(Equal(0))
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
|
||||||
podid := session.OutputToString()
|
|
||||||
|
|
||||||
session = podmanTest.RunTopContainerInPod("", podid)
|
session := podmanTest.RunTopContainerInPod("", podid)
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
@ -138,12 +132,10 @@ var _ = Describe("Podman pod stats", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman stats with json output", func() {
|
It("podman stats with json output", func() {
|
||||||
session := podmanTest.Podman([]string{"pod", "create"})
|
_, ec, podid := podmanTest.CreatePod("")
|
||||||
session.WaitWithDefaultTimeout()
|
Expect(ec).To(Equal(0))
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
|
||||||
podid := session.OutputToString()
|
|
||||||
|
|
||||||
session = podmanTest.RunTopContainerInPod("", podid)
|
session := podmanTest.RunTopContainerInPod("", podid)
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user