Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman: Wrap the start command with cgroup manager too #8001

Merged
merged 4 commits into from
May 11, 2020
Merged
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
3 changes: 1 addition & 2 deletions pkg/drivers/kic/kic.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ func (d *Driver) Restart() error {

// Start an already created kic container
func (d *Driver) Start() error {
cr := command.NewExecRunner() // using exec runner for interacting with docker/podman daemon
if _, err := cr.RunCmd(oci.PrefixCmd(exec.Command(d.NodeConfig.OCIBinary, "start", d.MachineName))); err != nil {
if err := oci.StartContainer(d.NodeConfig.OCIBinary, d.MachineName); err != nil {
return errors.Wrap(err, "start")
}
checkRunning := func() error {
Expand Down
23 changes: 22 additions & 1 deletion pkg/drivers/kic/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ func createContainer(ociBin string, image string, opts ...createOpt) error {
args := []string{"run"}

// to run nested container from privileged container in podman https://bugzilla.redhat.com/show_bug.cgi?id=1687713
if ociBin == Podman {
// only add when running locally (linux), when running remotely it needs to be configured on server in libpod.conf
if ociBin == Podman && runtime.GOOS == "linux" {
args = append(args, "--cgroup-manager", "cgroupfs")
}

Expand All @@ -254,6 +255,26 @@ func createContainer(ociBin string, image string, opts ...createOpt) error {
return nil
}

// StartContainer starts a container with "docker/podman start"
func StartContainer(ociBin string, container string) error {
// construct the actual docker start argv
args := []string{"start"}

// to run nested container from privileged container in podman https://bugzilla.redhat.com/show_bug.cgi?id=1687713
afbjorklund marked this conversation as resolved.
Show resolved Hide resolved
// only add when running locally (linux), when running remotely it needs to be configured on server in libpod.conf
if ociBin == Podman && runtime.GOOS == "linux" {
args = append(args, "--cgroup-manager", "cgroupfs")
afbjorklund marked this conversation as resolved.
Show resolved Hide resolved
}

args = append(args, container)

if _, err := runCmd(exec.Command(ociBin, args...)); err != nil {
return err
}

return nil
}

// ContainerID returns id of a container name
func ContainerID(ociBin string, nameOrID string) (string, error) {
rr, err := runCmd(exec.Command(ociBin, "inspect", "-f", "{{.Id}}", nameOrID))
Expand Down