Skip to content

feat: Clean up coder agent path in ps listing #2453

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

Merged
merged 1 commit into from
Jun 17, 2022

Conversation

mafredri
Copy link
Member

This commit changes the coder agent path in ps listing from
/tmp/tmp.coderwWs87Y/coder agent to ./coder agent.

The path is also updated to /tmp/coder.wWs87Y.

There were two options considered for turning ./coder agent into
coder agent:

  1. Run exec -a coder /path/to/coder agent
  2. Run PATH=/path/to:$PATH exec coder agent

Option 1 is not supported by dash, and thus discarded.

Option 2 duplicates functionality in coder agent which appends the
path, here we would want to prepend it to ensure we're starting the
downloaded coder binary in case there is a binary with a conflicting
name on the system.

Fixes #2407

This commit changes the `coder agent` path in `ps` listing from
`/tmp/tmp.coderwWs87Y/coder agent` to `./coder agent`.

The path is also updated to `/tmp/coder.wWs87Y`.

There were two options considered for turning `./coder agent` into
`coder agent`:

1. Run `exec -a coder /path/to/coder agent`
2. Run `PATH=/path/to:$PATH exec coder agent`

Option 1 is not supported by `dash`, and thus discarded.

Option 2 duplicates functionality in `coder agent` which _appends_ the
path, here we would want to _prepend_ it to ensure we're starting the
downloaded `coder` binary in case there is a binary with a conflicting
name on the system.

Fixes #2407
@mafredri mafredri self-assigned this Jun 17, 2022
@mafredri mafredri requested a review from a team June 17, 2022 10:17
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

This looks fine to me, although I haven't tested it.

We could also do that thing where you change argv[0] to modify the process name as it appears in ps, although I'm not sure how simple that is in Go.

@mafredri
Copy link
Member Author

We could also do that thing where you change argv[0] to modify the process name as it appears in ps, although I'm not sure how simple that is in Go.

I thought about the possibility of modifying it from the agent (or having the agent re-exec), but I don't think we want to change argv[0] when run (manually) by a user; so we'd need some additional logic/checks to see if we're running as part of the agent init script.

@mafredri mafredri merged commit 6c1208e into main Jun 17, 2022
@mafredri mafredri deleted the mafredri/agent-ps-cleanup branch June 17, 2022 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up coder agent ps listing in workspace
2 participants