Skip to content

Commit

Permalink
Wrap the start command with cgroup manager too
Browse files Browse the repository at this point in the history
When running with podman, to match the run cmd
  • Loading branch information
afbjorklund committed May 4, 2020
1 parent e0685c8 commit 29fb2b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/drivers/kic/kic.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,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
19 changes: 19 additions & 0 deletions pkg/drivers/kic/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,25 @@ 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
if ociBin == Podman {
args = append(args, "--cgroup-manager", "cgroupfs")
}

args = append(args, container)

if err := PrefixCmd(exec.Command(ociBin, args...)).Run(); 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

0 comments on commit 29fb2b4

Please sign in to comment.