Skip to content

Commit

Permalink
Run podman in privileged mode extracting the kubernetes tarball into …
Browse files Browse the repository at this point in the history
…the volume. Fixes #8016
  • Loading branch information
elegos committed May 6, 2020
1 parent f3d5c57 commit bd0b444
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/drivers/kic/oci/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"bytes"
"fmt"
"os/exec"
"runtime"
"strings"

"github.com/golang/glog"
Expand Down Expand Up @@ -80,7 +81,13 @@ func allVolumesByLabel(ociBin string, label string) ([]string, error) {
// ExtractTarballToVolume runs a docker image imageName which extracts the tarball at tarballPath
// to the volume named volumeName
func ExtractTarballToVolume(ociBin string, tarballPath, volumeName, imageName string) error {
cmd := exec.Command(ociBin, "run", "--rm", "--entrypoint", "/usr/bin/tar", "-v", fmt.Sprintf("%s:/preloaded.tar:ro", tarballPath), "-v", fmt.Sprintf("%s:/extractDir", volumeName), imageName, "-I", "lz4", "-xvf", "/preloaded.tar", "-C", "/extractDir")
cmdArgs := []string{"run", "--rm", "--entrypoint"}
// if not running in privileged mode, /preloaded.tar will have no permissions (-?????????)
if ociBin == Podman && runtime.GOOS == "linux" {
cmdArgs = append(cmdArgs, "--privileged")
}
cmdArgs = append(cmdArgs, "/usr/bin/tar", "-v", fmt.Sprintf("%s:/preloaded.tar:ro", tarballPath), "-v", fmt.Sprintf("%s:/extractDir", volumeName), imageName, "-I", "lz4", "-xvf", "/preloaded.tar", "-C", "/extractDir")
cmd := exec.Command(ociBin, cmdArgs...)
if _, err := runCmd(cmd); err != nil {
return err
}
Expand Down

0 comments on commit bd0b444

Please sign in to comment.