summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-11 10:56:11 -0400
committerGitHub <noreply@github.com>2020-06-11 10:56:11 -0400
commit39ad0387ca27097875b02b55c6f71c2f2b8bdd6c (patch)
tree0c870e02eb98c1f1db60d5dd44e7ebf2a7450335 /libpod
parentf1b6840382ffdfe9811c64b3aea75218d9b14e5e (diff)
parentc7c81a8c081f6f7458345027f315a796d6ca5eda (diff)
downloadpodman-39ad0387ca27097875b02b55c6f71c2f2b8bdd6c.tar.gz
podman-39ad0387ca27097875b02b55c6f71c2f2b8bdd6c.tar.bz2
podman-39ad0387ca27097875b02b55c6f71c2f2b8bdd6c.zip
Merge pull request #6415 from vrothberg/systemd-new-pod
podman-generate-systemd --new for pods
Diffstat (limited to 'libpod')
-rw-r--r--libpod/define/pod_inspect.go3
-rw-r--r--libpod/options.go24
-rw-r--r--libpod/pod.go25
-rw-r--r--libpod/pod_api.go1
-rw-r--r--libpod/runtime_pod_infra_linux.go3
5 files changed, 56 insertions, 0 deletions
diff --git a/libpod/define/pod_inspect.go b/libpod/define/pod_inspect.go
index 26fd2cab4..7f06e16fc 100644
--- a/libpod/define/pod_inspect.go
+++ b/libpod/define/pod_inspect.go
@@ -18,6 +18,9 @@ type InspectPodData struct {
Namespace string `json:"Namespace,omitempty"`
// Created is the time when the pod was created.
Created time.Time
+ // CreateCommand is the full command plus arguments of the process the
+ // container has been created with.
+ CreateCommand []string `json:"CreateCommand,omitempty"`
// State represents the current state of the pod.
State string `json:"State"`
// Hostname is the hostname that the pod will set.
diff --git a/libpod/options.go b/libpod/options.go
index 8e0d3df86..5a0f60093 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -1538,6 +1538,30 @@ func WithPodHostname(hostname string) PodCreateOption {
}
}
+// WithPodCreateCommand adds the full command plus arguments of the current
+// process to the pod config.
+func WithPodCreateCommand() PodCreateOption {
+ return func(pod *Pod) error {
+ if pod.valid {
+ return define.ErrPodFinalized
+ }
+ pod.config.CreateCommand = os.Args
+ return nil
+ }
+}
+
+// WithInfraConmonPidFile sets the path to a custom conmon PID file for the
+// infra container.
+func WithInfraConmonPidFile(path string) PodCreateOption {
+ return func(pod *Pod) error {
+ if pod.valid {
+ return define.ErrPodFinalized
+ }
+ pod.config.InfraContainer.ConmonPidFile = path
+ return nil
+ }
+}
+
// WithPodLabels sets the labels of a pod.
func WithPodLabels(labels map[string]string) PodCreateOption {
return func(pod *Pod) error {
diff --git a/libpod/pod.go b/libpod/pod.go
index 8afaa6052..bf0d7a397 100644
--- a/libpod/pod.go
+++ b/libpod/pod.go
@@ -64,6 +64,10 @@ type PodConfig struct {
// Time pod was created
CreatedTime time.Time `json:"created"`
+ // CreateCommand is the full command plus arguments of the process the
+ // container has been created with.
+ CreateCommand []string `json:"CreateCommand,omitempty"`
+
// ID of the pod's lock
LockID uint32 `json:"lockID"`
}
@@ -79,6 +83,7 @@ type podState struct {
// InfraContainerConfig is the configuration for the pod's infra container
type InfraContainerConfig struct {
+ ConmonPidFile string `json:"conmonPidFile"`
HasInfraContainer bool `json:"makeInfraContainer"`
HostNetwork bool `json:"infraHostNetwork,omitempty"`
PortBindings []ocicni.PortMapping `json:"infraPortBindings"`
@@ -124,6 +129,12 @@ func (p *Pod) CreatedTime() time.Time {
return p.config.CreatedTime
}
+// CreateCommand returns the os.Args of the process with which the pod has been
+// created.
+func (p *Pod) CreateCommand() []string {
+ return p.config.CreateCommand
+}
+
// CgroupParent returns the pod's CGroup parent
func (p *Pod) CgroupParent() string {
return p.config.CgroupParent
@@ -246,6 +257,20 @@ func (p *Pod) InfraContainerID() (string, error) {
return p.state.InfraContainerID, nil
}
+// InfraContainer returns the infra container.
+func (p *Pod) InfraContainer() (*Container, error) {
+ if !p.HasInfraContainer() {
+ return nil, errors.Wrap(define.ErrNoSuchCtr, "pod has no infra container")
+ }
+
+ id, err := p.InfraContainerID()
+ if err != nil {
+ return nil, err
+ }
+
+ return p.runtime.state.Container(id)
+}
+
// TODO add pod batching
// Lock pod to avoid lock contention
// Store and lock all containers (no RemoveContainer in batch guarantees cache will not become stale)
diff --git a/libpod/pod_api.go b/libpod/pod_api.go
index e2c4b515d..c8605eb69 100644
--- a/libpod/pod_api.go
+++ b/libpod/pod_api.go
@@ -489,6 +489,7 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) {
Name: p.Name(),
Namespace: p.Namespace(),
Created: p.CreatedTime(),
+ CreateCommand: p.config.CreateCommand,
State: podState,
Hostname: p.config.Hostname,
Labels: p.Labels(),
diff --git a/libpod/runtime_pod_infra_linux.go b/libpod/runtime_pod_infra_linux.go
index 06a7b3936..a0dee3aa1 100644
--- a/libpod/runtime_pod_infra_linux.go
+++ b/libpod/runtime_pod_infra_linux.go
@@ -130,6 +130,9 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, rawIm
options = append(options, WithRootFSFromImage(imgID, imgName, rawImageName))
options = append(options, WithName(containerName))
options = append(options, withIsInfra())
+ if len(p.config.InfraContainer.ConmonPidFile) > 0 {
+ options = append(options, WithConmonPidFile(p.config.InfraContainer.ConmonPidFile))
+ }
return r.newContainer(ctx, g.Config, options...)
}