Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5746401

Browse files
committed
make adjusting resource scores non-fatal
1 parentb68a46a commit5746401

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

‎agent/agentexec/cli_linux.go‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const unset = -2000
2323
// CLI runs the agent-exec command. It should only be called by the cli package.
2424
funcCLI()error {
2525
// We lock the OS thread here to avoid a race condition where the nice priority
26-
// we get is on a different thread from the one we set it on.
26+
// we set gets applied to a different thread than the one we exec the provided
27+
// command on.
2728
runtime.LockOSThread()
2829
// Nop on success but we do it anyway in case of an error.
2930
deferruntime.UnlockOSThread()
@@ -68,12 +69,18 @@ func CLI() error {
6869

6970
err=unix.Setpriority(unix.PRIO_PROCESS,0,*nice)
7071
iferr!=nil {
71-
returnxerrors.Errorf("set nice score: %w",err)
72+
// We alert the user instead of failing the command since it can be difficult to debug
73+
// for a template admin otherwise. It's quite possible (and easy) to set an
74+
// inappriopriate value for niceness.
75+
printfStdErr("failed to adjust niceness to %q: %v",*nice,err)
7276
}
7377

7478
err=writeOOMScoreAdj(*oom)
7579
iferr!=nil {
76-
returnxerrors.Errorf("set oom score: %w",err)
80+
// We alert the user instead of failing the command since it can be difficult to debug
81+
// for a template admin otherwise. It's quite possible (and easy) to set an
82+
// inappriopriate value for oom_score_adj.
83+
printfStdErr("failed to adjust oom score to %q: %v",*nice,err)
7784
}
7885

7986
path,err:=exec.LookPath(args[0])
@@ -143,3 +150,7 @@ func execArgs(args []string) []string {
143150
}
144151
returnnil
145152
}
153+
154+
funcprintfStdErr(formatstring,a...any) {
155+
_,_=fmt.Fprintf(os.Stderr,"coder-agent: %s\n",fmt.Sprintf(format,a...))
156+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp