Skip to content

Commit

Permalink
Merge pull request #29 from liamawhite/command-debug
Browse files Browse the repository at this point in the history
Warn on command failure to improve debugging
  • Loading branch information
liamawhite authored Aug 28, 2024
2 parents 0d19045 + 36a7427 commit 5b45fe0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/provider/resource_local_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,12 @@ func (r *LocalCommandResource) RunCommand(ctx context.Context, data *LocalComman
}
err = cmd.Wait()
if err != nil {
tflog.Trace(ctx, fmt.Sprintf("ATTEMPT #%d exit_code=%d", attempt, err.(*exec.ExitError).ExitCode()))
tflog.Warn(ctx, fmt.Sprintf("ATTEMPT #%d exit_code=%d", attempt, err.(*exec.ExitError).ExitCode()))
data.Stdout = types.StringValue(stdout.String())
data.Stderr = types.StringValue(stderr.String())
tflog.Debug(ctx, fmt.Sprintf("Command stdout: %s", stdout.String()))
tflog.Debug(ctx, fmt.Sprintf("Command stdout: %s", stderr.String()))
tflog.Warn(ctx, fmt.Sprintf("Command string: sh -c %s", data.Command.ValueString()))
tflog.Warn(ctx, fmt.Sprintf("Command stdout: %s", stdout.String()))
tflog.Warn(ctx, fmt.Sprintf("Command stderr: %s", stderr.String()))
return false
}
tflog.Trace(ctx, fmt.Sprintf("SUCCESS [%d/%d]", successes, data.ConsecutiveSuccesses.ValueInt64()))
Expand Down

0 comments on commit 5b45fe0

Please sign in to comment.