Skip to content

Commit

Permalink
Fix a problem, when there are multiple running operations at the same…
Browse files Browse the repository at this point in the history
… time
  • Loading branch information
loburm committed Mar 26, 2024
1 parent 2f66f25 commit 7ae9efc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kubetest/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,15 +946,15 @@ func (g *gkeDeployer) Down() error {
return fmt.Errorf("failed to list clusters in project %s with filter (name=%s AND location=%s): %w", g.project, g.cluster, g.locationRaw, err)
}

operationNameBytes, err := control.Output(exec.Command(
operationNamesBytes, err := control.Output(exec.Command(
"gcloud", g.containerArgs("operations", "list", "--project="+g.project,
g.location, "--format=value(name)", fmt.Sprintf("--filter=(status!=DONE AND (targetLink ~ /clusters/%s$ OR targetLink ~ /clusters/%s/))", g.cluster, g.cluster))...))
if err != nil {
return fmt.Errorf("failed to list not DONE operations for cluster %s: %w", g.cluster, err)
}

operationName := strings.TrimSpace(string(operationNameBytes))
if operationName != "" {
operationNames := strings.Split(strings.TrimSpace(string(operationNameBytes)), "\n")
for _, operationName := range operationNames {
log.Printf("Found RUNNING operation %q blocking cluster deletion. Will wait for its completion.", operationName)
err := control.FinishRunning(exec.Command(
"gcloud", g.containerArgs("operations", "wait", "--project="+g.project,
Expand Down

0 comments on commit 7ae9efc

Please sign in to comment.