Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions cmd/podman/cliconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,18 @@ type KubePlayValues struct {

type PodCreateValues struct {
PodmanCommand
CgroupParent string
Infra bool
InfraImage string
InfraCommand string
LabelFile []string
Labels []string
Name string
Hostname string
PodIDFile string
Publish []string
Share string
CgroupParent string
PinNamespaces bool
Infra bool
InfraImage string
InfraCommand string
LabelFile []string
Labels []string
Name string
Hostname string
PodIDFile string
Publish []string
Share string
}

type PodInspectValues struct {
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pod_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func init() {
// Remember to do this safely by checking len, etc.

flags.StringVar(&podCreateCommand.CgroupParent, "cgroup-parent", "", "Set parent cgroup for the pod")
flags.BoolVarP(&podCreateCommand.PinNamespaces, "pin-namespaces", "i", false, "Pin namespaces instead of using an infra container")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now, the "instead of using an infra container" isn't quite correct. I would want to update the description once we can actually drop the infra container

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see that's the eventual intention of this PR, nevermind 😄

flags.BoolVar(&podCreateCommand.Infra, "infra", true, "Create an infra container associated with the pod to share namespaces with")
flags.StringVar(&podCreateCommand.InfraImage, "infra-image", define.DefaultInfraImage, "The image of the infra container to associate with the pod")
flags.StringVar(&podCreateCommand.InfraCommand, "infra-command", define.DefaultInfraCommand, "The command to run on the infra container when the pod is started")
Expand Down
33 changes: 33 additions & 0 deletions cmd/podman/shared/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,39 @@ func configurePod(c *GenericCLIResults, runtime *libpod.Runtime, namespaces map[
if err != nil {
return namespaces, "", err
}

if pod.PinNamespaces() {
return configurePodForPinnedNamespaces(c, runtime, namespaces, pod)
}
return configurePodForInfraContainer(c, runtime, namespaces, pod)
}

func configurePodForPinnedNamespaces(c *GenericCLIResults, runtime *libpod.Runtime, namespaces map[string]string, pod *libpod.Pod) (map[string]string, string, error) {
pinnedNamespacesPath, err := pod.PinnedNamespacesPath()
if err != nil {
return nil, "", errors.Wrap(err, "unable to retrieve pod’s pinned namespaces path")
}

/* if (namespaces["cgroup"] == cc.Pod) || (!c.IsSet("cgroupns") && pod.SharesCgroup()) {
namespaces["cgroup"] = fmt.Sprintf("ns:%s", filepath.Join(pinnedNamespacesPath, "cgroup"))
}
if (namespaces["pid"] == cc.Pod) || (!c.IsSet("pid") && pod.SharesPID()) {
namespaces["pid"] = fmt.Sprintf("ns:%s", filepath.Join(pinnedNamespacesPath, "pid"))
} */

if (namespaces["net"] == cc.Pod) || (!c.IsSet("net") && !c.IsSet("network") && pod.SharesNet()) {
namespaces["net"] = fmt.Sprintf("ns:%s", filepath.Join(pinnedNamespacesPath, "net"))
}
if (namespaces["ipc"] == cc.Pod) || (!c.IsSet("ipc") && pod.SharesIPC()) {
namespaces["ipc"] = fmt.Sprintf("ns:%s", filepath.Join(pinnedNamespacesPath, "ipc"))
}
if (namespaces["uts"] == cc.Pod) || (!c.IsSet("uts") && pod.SharesUTS()) {
namespaces["uts"] = fmt.Sprintf("ns:%s", filepath.Join(pinnedNamespacesPath, "uts"))
}
return namespaces, "", nil
}

func configurePodForInfraContainer(c *GenericCLIResults, runtime *libpod.Runtime, namespaces map[string]string, pod *libpod.Pod) (map[string]string, string, error) {
podInfraID, err := pod.InfraContainerID()
if err != nil {
return namespaces, "", err
Expand Down
8 changes: 1 addition & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.12

require (
github.com/BurntSushi/toml v0.3.1
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/buger/goterm v0.0.0-20181115115552-c206103e1f37
github.com/checkpoint-restore/go-criu v0.0.0-20190109184317-bdb7599cd87b
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
Expand All @@ -16,7 +15,6 @@ require (
github.com/containers/psgo v1.4.0
github.com/containers/storage v1.15.8
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/cri-o/ocicni v0.1.1-0.20190920040751-deac903fd99b
github.com/cyphar/filepath-securejoin v0.2.2
github.com/davecgh/go-spew v1.1.1
Expand Down Expand Up @@ -69,17 +67,13 @@ require (
github.com/uber/jaeger-lib v0.0.0-20190122222657-d036253de8f5 // indirect
github.com/varlink/go v0.0.0-20190502142041-0f1d566d194b
github.com/vishvananda/netlink v1.1.0
go.uber.org/atomic v1.4.0 // indirect
golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/genproto v0.0.0-20190620144150-6af8c5fc6601 // indirect
gopkg.in/yaml.v2 v2.2.8
gotest.tools/v3 v3.0.2 // indirect
k8s.io/api v0.17.3
k8s.io/apimachinery v0.17.3
k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
k8s.io/utils v0.0.0-20190607212802-c55fbcfc754a // indirect
k8s.io/release v0.2.4-0.20200214094417-6f893148a75f
)
Loading