-
Notifications
You must be signed in to change notification settings - Fork 887
feat: add agent exec pkg #15577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add agent exec pkg #15577
Conversation
@spikecurtis @deansheather should our inability to adjust scores for oom or niceness result in a fatal error? If you misconfigure the numbers you've effectively bricked your template. |
I would say no |
return 0, xerrors.Errorf("get nice score: %w", err) | ||
} | ||
// See https://linux.die.net/man/2/setpriority#Notes | ||
score = 20 - score |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why we're translating from kernel to userspace scores here if we just call Setpriority()
with this value. Shouldn't we need to translate back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getpriority
man page says the following:
The getpriority system call returns nice values translated to the
range 40..1, since a negative return value would be interpreted
as an error. The glibc wrapper function for getpriority()
translates the value back according to the formula
unice = 20 - knice (thus, the 40..1 range returned by the kernel
corresponds to the range -20..19 as seen by user space).
Further up it says the following for setpriority
:
The prio argument is a value in the range -20 to 19 (but see
NOTES below), with -20 being the highest priority and 19 being
the lowest priority. Attempts to set a priority outside this
range are silently clamped to the range. The default priority is
0; lower values give a process a higher scheduling priority.
Pretty confusing tbh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woof. OK, initially read this as glibc doing the translation in both cases, but I guess it's only the get operation that has issues with negative numbers.
This PR adds an
agentexec
pkg with the intention of eventually replacing the current way we manage process priority in workspaces. The intent is for every invocation ofexec.Command()
to be wrapped byagentexec.Command
to ensure that we adjust the niceness and oom_score appropriately.