From 59b8aee799918c9634450ceab4dfc070421652a2 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 27 Nov 2024 18:59:58 +0000 Subject: [PATCH 1/2] fix: add additional context to agent exec errors --- agent/agentexec/cli_linux.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/agent/agentexec/cli_linux.go b/agent/agentexec/cli_linux.go index d729a53c826dc..6350ee5bd24af 100644 --- a/agent/agentexec/cli_linux.go +++ b/agent/agentexec/cli_linux.go @@ -69,18 +69,26 @@ func CLI() error { err = unix.Setpriority(unix.PRIO_PROCESS, 0, *nice) if err != nil { +<<<<<<< Updated upstream // We alert the user instead of failing the command since it can be difficult to debug // for a template admin otherwise. It's quite possible (and easy) to set an // inappriopriate value for niceness. printfStdErr("failed to adjust niceness to %q: %v", *nice, err) +======= + return xerrors.Errorf("set nice score for cmd %v: %w", args, err) +>>>>>>> Stashed changes } err = writeOOMScoreAdj(*oom) if err != nil { +<<<<<<< Updated upstream // We alert the user instead of failing the command since it can be difficult to debug // for a template admin otherwise. It's quite possible (and easy) to set an // inappriopriate value for oom_score_adj. printfStdErr("failed to adjust oom score to %q: %v", *nice, err) +======= + return xerrors.Errorf("set oom score for cmd %v: %w", args, err) +>>>>>>> Stashed changes } path, err := exec.LookPath(args[0]) @@ -138,7 +146,7 @@ func oomScoreAdj() (int, error) { } func writeOOMScoreAdj(score int) error { - return os.WriteFile("/proc/self/oom_score_adj", []byte(fmt.Sprintf("%d", score)), 0o600) + return os.WriteFile(fmt.Sprintf("/proc/%d/oom_score_adj", os.Getpid()), []byte(fmt.Sprintf("%d", score)), 0o600) } // execArgs returns the arguments to pass to syscall.Exec after the "--" delimiter. From ed49778181fc56b662118d0bc9c18ed74e614ca3 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 27 Nov 2024 19:04:26 +0000 Subject: [PATCH 2/2] conflicts --- agent/agentexec/cli_linux.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/agent/agentexec/cli_linux.go b/agent/agentexec/cli_linux.go index 6350ee5bd24af..8c4acb9060a2e 100644 --- a/agent/agentexec/cli_linux.go +++ b/agent/agentexec/cli_linux.go @@ -69,26 +69,18 @@ func CLI() error { err = unix.Setpriority(unix.PRIO_PROCESS, 0, *nice) if err != nil { -<<<<<<< Updated upstream // We alert the user instead of failing the command since it can be difficult to debug // for a template admin otherwise. It's quite possible (and easy) to set an // inappriopriate value for niceness. - printfStdErr("failed to adjust niceness to %q: %v", *nice, err) -======= - return xerrors.Errorf("set nice score for cmd %v: %w", args, err) ->>>>>>> Stashed changes + printfStdErr("failed to adjust niceness to %d for cmd %+v: %v", *nice, args, err) } err = writeOOMScoreAdj(*oom) if err != nil { -<<<<<<< Updated upstream // We alert the user instead of failing the command since it can be difficult to debug // for a template admin otherwise. It's quite possible (and easy) to set an // inappriopriate value for oom_score_adj. - printfStdErr("failed to adjust oom score to %q: %v", *nice, err) -======= - return xerrors.Errorf("set oom score for cmd %v: %w", args, err) ->>>>>>> Stashed changes + printfStdErr("failed to adjust oom score to %d for cmd %+v: %v", *oom, args, err) } path, err := exec.LookPath(args[0])