Merge pull request #7262 from priyawadhwa/preload-error-logging
Add more logging to preloadpull/7044/head^2
commit
6ef3faf6a2
|
|
@ -23,6 +23,7 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/minikube/pkg/minikube/download"
|
||||
"k8s.io/minikube/pkg/minikube/exit"
|
||||
)
|
||||
|
|
@ -45,6 +46,7 @@ func init() {
|
|||
if k8sVersion != "" {
|
||||
k8sVersions = append(k8sVersions, k8sVersion)
|
||||
}
|
||||
viper.Set("preload", "true")
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
@ -62,7 +64,7 @@ func main() {
|
|||
for _, kv := range k8sVersions {
|
||||
for _, cr := range containerRuntimes {
|
||||
tf := download.TarballName(kv)
|
||||
if tarballExists(tf) {
|
||||
if download.PreloadExists(kv, cr) {
|
||||
fmt.Printf("A preloaded tarball for k8s version %s already exists, skipping generation.\n", kv)
|
||||
continue
|
||||
}
|
||||
|
|
@ -77,13 +79,6 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func tarballExists(tarballFilename string) bool {
|
||||
fmt.Println("Checking if tarball already exists...")
|
||||
gcsPath := fmt.Sprintf("gs://%s/%s", download.PreloadBucket, tarballFilename)
|
||||
cmd := exec.Command("gsutil", "stat", gcsPath)
|
||||
return cmd.Run() == nil
|
||||
}
|
||||
|
||||
func verifyDockerStorage() error {
|
||||
cmd := exec.Command("docker", "info", "-f", "{{.Info.Driver}}")
|
||||
var stderr bytes.Buffer
|
||||
|
|
|
|||
|
|
@ -30,13 +30,22 @@ func uploadTarball(tarballFilename string) error {
|
|||
hostPath := path.Join("out/", tarballFilename)
|
||||
gcsDest := fmt.Sprintf("gs://%s", download.PreloadBucket)
|
||||
cmd := exec.Command("gsutil", "cp", hostPath, gcsDest)
|
||||
if output, err := cmd.Output(); err != nil {
|
||||
fmt.Printf("Running: %v\n", cmd.Args)
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
return errors.Wrapf(err, "uploading %s to GCS bucket: %v\n%s", hostPath, err, string(output))
|
||||
}
|
||||
// Make tarball public to all users
|
||||
gcsPath := fmt.Sprintf("%s/%s", gcsDest, tarballFilename)
|
||||
cmd = exec.Command("gsutil", "acl", "ch", "-u", "AllUsers:R", gcsPath)
|
||||
if output, err := cmd.Output(); err != nil {
|
||||
fmt.Printf("Running: %v\n", cmd.Args)
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
fmt.Printf(`Failed to update ACLs on this tarball in GCS. Please run
|
||||
|
||||
gsutil acl ch -u AllUsers:R %s
|
||||
|
||||
manually to make this link public, or rerun this script to rebuild and reupload the tarball.
|
||||
|
||||
`, gcsPath)
|
||||
return errors.Wrapf(err, "uploading %s to GCS bucket: %v\n%s", hostPath, err, string(output))
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ func remoteTarballURL(k8sVersion string) string {
|
|||
|
||||
// PreloadExists returns true if there is a preloaded tarball that can be used
|
||||
func PreloadExists(k8sVersion, containerRuntime string) bool {
|
||||
glog.Infof("Checking if preload exists for k8s version %s and runtime %s", k8sVersion, containerRuntime)
|
||||
if !viper.GetBool("preload") {
|
||||
return false
|
||||
}
|
||||
|
|
@ -85,6 +86,7 @@ func PreloadExists(k8sVersion, containerRuntime string) bool {
|
|||
// and https://github.com/kubernetes/minikube/issues/6934
|
||||
// to track status of adding containerd & crio
|
||||
if containerRuntime != "docker" {
|
||||
glog.Info("Container runtime isn't docker, skipping preload")
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue