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: error message with stdout/stderr in the case of sharing command fails #1984

Merged
merged 4 commits into from
Nov 29, 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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ Given a version number `MAJOR.MINOR.PATCH`, we increment the:

- Fix the command-line parsing of `run` and `script run` which were not failing from unknown flags.
- Fix `create --all-terragrunt` creating Terragrunt stacks with cycles.
- Panic in the Terragrunt integration when the project had modules with dependency paths outside the current Terramate project.
- Now Terramate throw a warning for such configurations.
- Improve the error reporting of the Outputs Sharing feature.
- Fix crash in the Terragrunt integration when the project had modules with dependency paths outside the current Terramate project.
- A warning will be shown for such configurations.

## v0.11.3

Expand Down
7 changes: 5 additions & 2 deletions cmd/terramate/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func (c *cli) runAll(
err := cmd.Run()
if err != nil {
if !task.MockOnFail {
errs.Append(errors.E(err, "failed to execute: %s (stderr: %s)", cmd.String(), stderr.Bytes()))
errs.Append(errors.E(err, "failed to execute: (cmd: %s) (stdout: %s) (stderr: %s)", cmd.String(), stdout.String(), stderr.String()))
c.cloudSyncAfter(cloudRun, runResult{ExitCode: -1}, errors.E(ErrRunCommandNotExecuted, err))
releaseResource()
failedTaskIndex = taskIndex
Expand All @@ -502,7 +502,10 @@ func (c *cli) runAll(
break tasksLoop
}

printer.Stderr.Warnf("failed to execute `sharing_backend` command: %v", err)
printer.Stderr.WarnWithDetails(
"failed to execute `sharing_backend` command",
errors.E(err, "(cmd: %s) (stdout: %s) (stderr: %s)", cmd.String(), stdout.String(), stderr.String()),
)
} else {
stdoutBytes := stdout.Bytes()
typ, err := json.ImpliedType(stdoutBytes)
Expand Down
6 changes: 3 additions & 3 deletions e2etests/core/run_parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,23 @@ func TestParallelSharingOutputFailure(t *testing.T) {
RunExpected{
Status: 1,
IgnoreStdout: true,
StderrRegex: regexp.QuoteMeta("failed to execute: does_not_exist"),
StderrRegex: regexp.QuoteMeta("failed to execute: (cmd: does_not_exist)"),
},
)
AssertRunResult(t,
tmcli.Run("run", "--enable-sharing", "--continue-on-error", "--parallel=2", "--quiet", "--", HelperPath, "echo", "okay"),
RunExpected{
Status: 1,
IgnoreStdout: true,
StderrRegex: regexp.QuoteMeta("failed to execute: does_not_exist"),
StderrRegex: regexp.QuoteMeta("failed to execute: (cmd: does_not_exist)"),
},
)
AssertRunResult(t,
tmcli.Run("run", "--dry-run", "--enable-sharing", "--continue-on-error", "--parallel=2", "--quiet", "--", HelperPath, "echo", "okay"),
RunExpected{
Status: 1,
IgnoreStdout: true,
StderrRegex: regexp.QuoteMeta("failed to execute: does_not_exist"),
StderrRegex: regexp.QuoteMeta("failed to execute: (cmd: does_not_exist)"),
},
)
}
Expand Down
5 changes: 4 additions & 1 deletion e2etests/core/run_sharing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ func TestRunSharing(t *testing.T) {
"local_file.s3_file",
},
NoStdoutRegex: "local_file.s2_file",
StderrRegex: regexp.QuoteMeta("Warning: failed to execute `sharing_backend` command: exit status 1"),
StderrRegexes: []string{
regexp.QuoteMeta("Warning: failed to execute `sharing_backend`"),
regexp.QuoteMeta("helper exit 1) (stdout: ) (stderr: ): exit status 1"),
},
})
},
},
Expand Down
Loading