diff --git a/src/pkg/packager/actions.go b/src/pkg/packager/actions.go index 78340d515f..f565bb727a 100644 --- a/src/pkg/packager/actions.go +++ b/src/pkg/packager/actions.go @@ -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) } } diff --git a/src/test/e2e/02_component_actions_test.go b/src/test/e2e/02_component_actions_test.go index bb3b25ffd3..6eda343103 100644 --- a/src/test/e2e/02_component_actions_test.go +++ b/src/test/e2e/02_component_actions_test.go @@ -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") }) }