Use download.TarballExists to make sure tarball is publicly accessible in script generator

pull/7262/head
Priya Wadhwa 2020-03-26 10:23:30 -07:00
parent efbe113a94
commit 2768552361
2 changed files with 8 additions and 8 deletions

View File

@ -62,7 +62,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 +77,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

View File

@ -37,6 +37,13 @@ func uploadTarball(tarballFilename string) error {
gcsPath := fmt.Sprintf("%s/%s", gcsDest, tarballFilename)
cmd = exec.Command("gsutil", "acl", "ch", "-u", "AllUsers:R", gcsPath)
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