Merge pull request #8001 from afbjorklund/podman-start

podman: Wrap the start command with cgroup manager too
pull/8071/head
Medya Ghazizadeh 2020-05-11 17:59:39 +00:00 committed by GitHub
commit 6b97ee8ee2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -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 {

View File

@ -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")
}
@ -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
// 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")
}
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))