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

Handle non existent cluster down gracefully #725

Closed
Closed
Changes from all 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
15 changes: 11 additions & 4 deletions test/k8s-integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ func clusterDownGKE(gceZone, gceRegion string) error {
return err
}

cmd := exec.Command("gcloud", "container", "clusters", "delete", *gkeTestClusterName,
locationArg, locationVal, "--quiet")
err = runCommand("Bringing Down E2E Cluster on GKE", cmd)
if err != nil {
klog.Infof("Bringing down GKE cluster %v, location arg %v, location val %v", *gkeTestClusterName, locationArg, locationVal)
out, err := exec.Command("gcloud", "container", "clusters", "delete", *gkeTestClusterName,
locationArg, locationVal, "--quiet").CombinedOutput()
klog.Infof("cluster delete output:\n%v", string(out))
if err != nil && !isNotFoundError(string(out)) {
return fmt.Errorf("failed to bring down kubernetes e2e cluster on gke: %v", err)
}

return nil
}

Expand Down Expand Up @@ -152,6 +154,7 @@ func clusterUpGKE(gceZone, gceRegion string, numNodes int, imageType string, use
return fmt.Errorf("failed to check for previous test cluster: %v %s", err, out)
}
if len(out) > 0 {
klog.Infof("cluster list output: %v", string(out))
klog.Infof("Detected previous cluster %s. Deleting so a new one can be created...", *gkeTestClusterName)
err = clusterDownGKE(gceZone, gceRegion)
if err != nil {
Expand Down Expand Up @@ -406,3 +409,7 @@ func isGKEDeploymentInstalledByDefault(clusterVersion string) bool {
cv.lessThan(mustParseVersion("1.19.0")) ||
cv.atLeast(mustParseVersion("1.19.3-gke.2100"))
}

func isNotFoundError(errstr string) bool {
return strings.Contains(strings.ToLower(errstr), "code=404")
}