Skip to content

Commit

Permalink
chore(e2e/vmcompose): fix retry check logic (#2656)
Browse files Browse the repository at this point in the history
Fix check function logic since the error doesn't contain "Permission
denied" but rather the `output` does.

issue: #2629
  • Loading branch information
corverroos authored Dec 9, 2024
1 parent a4e3945 commit 33b18fa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions e2e/vmcompose/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,17 @@ func copyFileToVM(ctx context.Context, vmName string, localPath string, remotePa
scp := fmt.Sprintf("gcloud compute scp --zone=us-east1-c --quiet %s %s:%s", localPath, vmName, remotePath)

// Scp sporadically fails with "Permission denied" on GCP, retry a few times.
errPermission := errors.New("scp permission denied")
check := func(err error) bool {
return strings.Contains(err.Error(), "Permission denied")
return errors.Is(err, errPermission)
}

do := func() error {
cmd := exec.CommandContext(ctx, "bash", "-c", scp)
out, err := cmd.CombinedOutput()
if err != nil {
if err != nil && strings.Contains(string(out), "Permission denied") {
return errors.Wrap(errPermission, "copy to VM", "output", string(out), "cmd", scp)
} else if err != nil {
return errors.Wrap(err, "copy to VM", "output", string(out), "cmd", scp)
}

Expand Down

0 comments on commit 33b18fa

Please sign in to comment.