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

fix(agent): filter outGOTRACEBACK=none#16924

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 2 commits intomainfrommafredri/fix-agent-go1241-gotraceback-none
Mar 17, 2025

Conversation

mafredri
Copy link
Member

With the switch to Go 1.24.1, our dogfood workspaces started setting
GOTRACEBACK=none in the environment, resulting in missing stacktraces
for users.

This is due to the capability changes we do when
USE_CAP_NET_ADMIN=true.

# If running as root, we do not need to do anything.
if ["$(id -u)"-eq 0 ];then
echo"Running as root, skipping setcap"
# Warn the user if root does not have CAP_NET_ADMIN.
if! capsh --has-p=CAP_NET_ADMIN;then
printnetadminmissing
fi
# If not running as root, make sure we have sudo perms and the "setcap" +
# "capsh" binaries exist.
elif sudo -nl&& haslibcap2;then
# Make sure the root user has CAP_NET_ADMIN.
if sudo -n capsh --has-p=CAP_NET_ADMIN;then
sudo -n setcap CAP_NET_ADMIN=+ep ./$BINARY_NAME||true
else
printnetadminmissing
fi

This most likely triggers a change in securitybits which sets
_AT_SECURE for the process.

https://github.com/golang/go/blob/a1ddbdd3ef8b739aab53f20d6ed0a61c3474cf12/src/runtime/os_linux.go#L297-L327

Which in turn triggers secure mode:

https://github.com/golang/go/blob/a1ddbdd3ef8b739aab53f20d6ed0a61c3474cf12/src/runtime/security_unix.go

A better fix may be to read/proc/self/environ to figure out if this
was set by the runtime or manually, but I'm not sure we should care
about that. A template author can still set the environment on the agent
resource.

Seehttps://pkg.go.dev/runtime#hdr-Security

With the switch to Go 1.24.1, our dogfood workspaces started setting`GOTRACEBACK=none` in the environment, resulting in missing stacktracesfor users.This is due to the capability changes we do when`USE_CAP_NET_ADMIN=true`.https://github.com/coder/coder/blob/564b387262e5b768c503e5317242d9ab576395d6/provisionersdk/scripts/bootstrap_linux.sh#L60-L76This most likely triggers a change in securitybits which sets`_AT_SECURE` for the process.https://github.com/golang/go/blob/a1ddbdd3ef8b739aab53f20d6ed0a61c3474cf12/src/runtime/os_linux.go#L297-L327Which in turn triggers secure mode:https://github.com/golang/go/blob/a1ddbdd3ef8b739aab53f20d6ed0a61c3474cf12/src/runtime/security_unix.goA better fix may be to read `/proc/self/environ` to figure out if thiswas set by the runtime or manually, but I'm not sure we should careabout that. A template author can still set the environment on the agentresource.Seehttps://pkg.go.dev/runtime#hdr-Security
// Ignore GOTRACEBACK=none, as it disables stack traces, it can
// be set on the agent due to changes in capabilities.
// https://pkg.go.dev/runtime#hdr-Security.
if e == "GOTRACEBACK=none" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is there any way for us to override this for ourselves that doesn't also override it for any user of coder? Seems like we're choosing for any user of coder that GOTRACEBACK shouldn't be set.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

On Linux, we could theoretically read/proc/self/environ to figure out if it was set externally or by the Go runtime. I'm not sure it's worth the lift though.

If someone sets this env in, say, a docker container resource. Yes, it will be filtered out for child-processes (which arguably may be the right thing to do anyway). But if someone sets it on the agent resource (which is the recommended way anyway), they absolutely still can.

sreya reacted with thumbs up emoji
@mafredrimafredri merged commitdf92df4 intomainMar 17, 2025
30 checks passed
@mafredrimafredri deleted the mafredri/fix-agent-go1241-gotraceback-none branchMarch 17, 2025 09:10
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 17, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@sreyasreyasreya approved these changes

Assignees

@mafredrimafredri

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@mafredri@sreya

[8]ページ先頭

©2009-2025 Movatter.jp