Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 24d44b4

Browse files
authored
fix: add additional context to agent exec errors (#15676)
1 parent b830c05 commit 24d44b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

agent/agentexec/cli_linux.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ func CLI() error {
7272
// We alert the user instead of failing the command since it can be difficult to debug
7373
// for a template admin otherwise. It's quite possible (and easy) to set an
7474
// inappriopriate value for niceness.
75-
printfStdErr("failed to adjust niceness to %q: %v", *nice, err)
75+
printfStdErr("failed to adjust niceness to %d for cmd %+v: %v", *nice, args, err)
7676
}
7777

7878
err = writeOOMScoreAdj(*oom)
7979
if err != nil {
8080
// We alert the user instead of failing the command since it can be difficult to debug
8181
// for a template admin otherwise. It's quite possible (and easy) to set an
8282
// inappriopriate value for oom_score_adj.
83-
printfStdErr("failed to adjust oom score to %q: %v", *nice, err)
83+
printfStdErr("failed to adjust oom score to %d for cmd %+v: %v", *oom, args, err)
8484
}
8585

8686
path, err := exec.LookPath(args[0])
@@ -138,7 +138,7 @@ func oomScoreAdj() (int, error) {
138138
}
139139

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

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

0 commit comments

Comments
 (0)