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

fix: improve cmd failure messaging #2301

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 7 additions & 4 deletions src/pkg/packager/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,15 @@ retryCmd:

select {
case <-timeout:
// If we reached this point, the timeout was reached.
return fmt.Errorf("command \"%s\" timed out after %d seconds", cmdEscaped, cfg.MaxTotalSeconds)

// If we reached this point, the timeout was reached or command failed with no retries.
if cfg.MaxTotalSeconds < 1 {
return fmt.Errorf("command %q failed after %d retries", cmdEscaped, cfg.MaxRetries)
} else {
return fmt.Errorf("command %q timed out after %d seconds", cmdEscaped, cfg.MaxTotalSeconds)
}
default:
// If we reached this point, the retry limit was reached.
return fmt.Errorf("command \"%s\" failed after %d retries", cmdEscaped, cfg.MaxRetries)
return fmt.Errorf("command %q failed after %d retries", cmdEscaped, cfg.MaxRetries)
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/e2e/02_component_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,7 @@ func TestComponentActions(t *testing.T) {
stdOut, stdErr, err = e2e.Zarf("package", "deploy", path, "--components=on-deploy-immediate-failure", "--confirm")
require.Error(t, err, stdOut, stdErr)
require.Contains(t, stdErr, "Failed to deploy package")
// regression test to ensure that failed commands are not erroneously flagged as a timeout
require.NotContains(t, stdErr, "timed out")
})
}
Loading