Use the actual storage driver name for cri-o

pull/8581/head
Anders F Björklund 2020-06-28 09:49:50 +02:00
parent 1bf268c9f6
commit b87a837f2e
2 changed files with 32 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"os"
@ -37,6 +38,7 @@ const (
var (
dockerStorageDriver = "overlay2"
podmanStorageDriver = "overlay"
containerRuntimes = []string{"docker", "containerd", "cri-o"}
k8sVersion string
k8sVersions []string
@ -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()
@ -113,6 +118,26 @@ func verifyDockerStorage() error {
return nil
}
func verifyPodmanStorage() error {
cmd := exec.Command("sudo", "podman", "info", "-f", "json")
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())

View File

@ -47,7 +47,13 @@ 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)
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