Skip to content

Commit 59b8aee

Browse files
committed
fix: add additional context to agent exec errors
1 parent b08238c commit 59b8aee

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

agent/agentexec/cli_linux.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,26 @@ func CLI() error {
6969

7070
err = unix.Setpriority(unix.PRIO_PROCESS, 0, *nice)
7171
if err != nil {
72+
<<<<<<< Updated upstream
7273
// We alert the user instead of failing the command since it can be difficult to debug
7374
// for a template admin otherwise. It's quite possible (and easy) to set an
7475
// inappriopriate value for niceness.
7576
printfStdErr("failed to adjust niceness to %q: %v", *nice, err)
77+
=======
78+
return xerrors.Errorf("set nice score for cmd %v: %w", args, err)
79+
>>>>>>> Stashed changes
7680
}
7781

7882
err = writeOOMScoreAdj(*oom)
7983
if err != nil {
84+
<<<<<<< Updated upstream
8085
// We alert the user instead of failing the command since it can be difficult to debug
8186
// for a template admin otherwise. It's quite possible (and easy) to set an
8287
// inappriopriate value for oom_score_adj.
8388
printfStdErr("failed to adjust oom score to %q: %v", *nice, err)
89+
=======
90+
return xerrors.Errorf("set oom score for cmd %v: %w", args, err)
91+
>>>>>>> Stashed changes
8492
}
8593

8694
path, err := exec.LookPath(args[0])
@@ -138,7 +146,7 @@ func oomScoreAdj() (int, error) {
138146
}
139147

140148
func writeOOMScoreAdj(score int) error {
141-
return os.WriteFile("/proc/self/oom_score_adj", []byte(fmt.Sprintf("%d", score)), 0o600)
149+
return os.WriteFile(fmt.Sprintf("/proc/%d/oom_score_adj", os.Getpid()), []byte(fmt.Sprintf("%d", score)), 0o600)
142150
}
143151

144152
// execArgs returns the arguments to pass to syscall.Exec after the "--" delimiter.

0 commit comments

Comments
 (0)