diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4af046..b8f9d77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,6 +107,9 @@ jobs: - name: Run unit tests run: make unit-test +# - name: Start SSH session +# uses: mxschmitt/action-tmate@v3 + - name: Run e2e tests run: make e2e-test if: matrix.os == 'ubuntu-latest' diff --git a/app/child.go b/app/child.go index 910da85..b9d4b7f 100644 --- a/app/child.go +++ b/app/child.go @@ -3,7 +3,6 @@ package app import ( "context" "fmt" - "log" "log/slog" "os" "os/exec" @@ -85,9 +84,22 @@ func RunChild(logger *slog.Logger, args []string) error { cmd.Stderr = os.Stderr err = cmd.Run() if err != nil { - log.Printf("failed to run %s: %v", bin, err) + // Check if this is a normal exit with non-zero status code + if exitError, ok := err.(*exec.ExitError); ok { + exitCode := exitError.ExitCode() + // Log at debug level for non-zero exits (normal behavior) + logger.Debug("Command exited with non-zero status", "exit_code", exitCode) + // Exit with the same code as the command - don't log as error + // This is normal behavior (commands can exit with any code) + os.Exit(exitCode) + } + // This is an unexpected error (not just a non-zero exit) + // Only log actual errors like "command not found" or "permission denied" + logger.Error("Command execution failed", "error", err) return err } + // Command exited successfully + logger.Debug("Command completed successfully") return nil } diff --git a/app/parent.go b/app/parent.go index 93afb43..4539219 100644 --- a/app/parent.go +++ b/app/parent.go @@ -5,6 +5,7 @@ import ( "fmt" "log/slog" "os" + "os/exec" "os/signal" "strings" "syscall" @@ -139,9 +140,18 @@ func RunParent(ctx context.Context, logger *slog.Logger, args []string, config C logger.Debug("waiting on a child process to finish") err = cmd.Wait() if err != nil { - logger.Error("Command execution failed", "error", err) + // Check if this is a normal exit with non-zero status code + if exitError, ok := err.(*exec.ExitError); ok { + exitCode := exitError.ExitCode() + // Log at debug level for non-zero exits (normal behavior) + logger.Debug("Command exited with non-zero status", "exit_code", exitCode) + } else { + // This is an unexpected error (not just a non-zero exit) + logger.Error("Command execution failed", "error", err) + } return } + logger.Debug("Command completed successfully") }() // Wait for signal or context cancellation