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

Generate cri-o container runtime preload tarball #8581

Merged
merged 6 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions hack/preload-images/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func imagePullCommand(containerRuntime, img string) *exec.Cmd {
if containerRuntime == "containerd" {
return exec.Command("docker", "exec", profile, "sudo", "crictl", "pull", img)
}

if containerRuntime == "cri-o" {
return exec.Command("docker", "exec", profile, "sudo", "crictl", "pull", img)
medyagh marked this conversation as resolved.
Show resolved Hide resolved
}
return nil
}

Expand All @@ -154,6 +158,10 @@ func createImageTarball(tarballFilename, containerRuntime string) error {
dirs = append(dirs, fmt.Sprintf("./lib/containerd"))
}

if containerRuntime == "cri-o" {
dirs = append(dirs, fmt.Sprintf("./lib/containers"))
}

args := []string{"exec", profile, "sudo", "tar", "-I", "lz4", "-C", "/var", "-cvf", tarballFilename}
args = append(args, dirs...)
cmd := exec.Command("docker", args...)
Expand Down
27 changes: 26 additions & 1 deletion hack/preload-images/preload_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"bytes"
"encoding/json"
"flag"
"fmt"
"os"
Expand All @@ -37,7 +38,8 @@ const (

var (
dockerStorageDriver = "overlay2"
containerRuntimes = []string{"docker", "containerd"}
podmanStorageDriver = "overlay"
containerRuntimes = []string{"docker", "containerd", "cri-o"}
k8sVersion string
k8sVersions []string
)
Expand Down Expand Up @@ -65,6 +67,9 @@ func main() {
if err := verifyDockerStorage(); err != nil {
exit("Docker storage type is incompatible: %v \n", err)
}
if err := verifyPodmanStorage(); err != nil {
exit("Podman storage type is incompatible: %v \n", err)
}
if k8sVersions == nil {
var err error
k8sVersions, err = RecentK8sVersions()
Expand Down Expand Up @@ -113,6 +118,26 @@ func verifyDockerStorage() error {
return nil
}

func verifyPodmanStorage() error {
cmd := exec.Command("sudo", "podman", "info", "-f", "json")
afbjorklund marked this conversation as resolved.
Show resolved Hide resolved
var stderr bytes.Buffer
cmd.Stderr = &stderr
output, err := cmd.Output()
if err != nil {
return fmt.Errorf("%v: %v:\n%s", cmd.Args, err, stderr.String())
}
var info map[string]map[string]interface{}
err = json.Unmarshal(output, &info)
if err != nil {
return err
}
driver := info["store"]["graphDriverName"]
if driver != podmanStorageDriver {
return fmt.Errorf("podman storage driver %s does not match requested %s", driver, podmanStorageDriver)
}
return nil
}

// exit will exit and clean up minikube
func exit(msg string, err error) {
fmt.Printf("WithError(%s)=%v called from:\n%s", msg, err, debug.Stack())
Expand Down
11 changes: 10 additions & 1 deletion pkg/minikube/download/preload.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ const (

// TarballName returns name of the tarball
func TarballName(k8sVersion, containerRuntime string) string {
return fmt.Sprintf("preloaded-images-k8s-%s-%s-%s-overlay2-%s.tar.lz4", PreloadVersion, k8sVersion, containerRuntime, runtime.GOARCH)
if containerRuntime == "crio" {
containerRuntime = "cri-o"
}
var storageDriver string
if containerRuntime == "cri-o" {
storageDriver = "overlay"
} else {
storageDriver = "overlay2"
}
return fmt.Sprintf("preloaded-images-k8s-%s-%s-%s-%s-%s.tar.lz4", PreloadVersion, k8sVersion, containerRuntime, storageDriver, runtime.GOARCH)
}

// returns the name of the checksum file
Expand Down