-
Notifications
You must be signed in to change notification settings - Fork 881
feat: set $HOME for coder agent in gcp-linux template #2147
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
Conversation
Signed-off-by: Spike Curtis <spike@coder.com>
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.
Have you verified that $HOME
isn't set already? I'm pretty sure it is by default on GCP, even in the startup script.
Yeah, have been playing around with this template. Existing code leaves the coder agent without a $HOME, and this fixes. |
I'm concerned customers will encounter this and encounter bugs without any clear path to resolve. Do you think having the default Linux behavior of |
I'm guessing you are suggesting that we add this to the I get the pragmatic argument, that these are very well known conventions around home directory, and am not aware of any Linux distribution that violates them. However, on any distribution people are free to put their homedir kind of anywhere they want. Ask yourself this question: if the right move is to fall back to convention if In this case, the missing I'm not opposed to the agent executing some "preflight checks" to catch missing |
JetBrains remote development solution is very new, while VS Code Remote handles this case just fine. I'd assume this is a bug on their end.
We'd add this to the agent. If |
Also note that what I'm doing in this PR is not a great long-term position because we are still executing the agent in a "non-standard" way by running it as root from the startup script. The right thing to do is to have the startup script (or terraform itself) install a systemd unit to run the coder agent as a normal user. The reason I'm not doing it here is that it's more involved and I want to unblock people from #1386 |
Can you give a little more detail here? In particular, I don't think "VS Code Remote runs just fine without |
VS Code Remote defaults to convention for the homedir. I'm not sure why we don't as well, because it seems like the user only excludes |
Ah, when I try to connect with VS Code Remote - SSH on a workspace where
But it works with my fixed code that sets the home dir. |
Ahh, that's a bad assumption on my part then. I suppose I'd say the onus is more on us in this instance because we're assisting with provisioning the environment and control the shells in userspace. Anything we have to apply to every(?) template seems we should have a general solution for, otherwise, customers will encounter the same issue. |
I do agree with this sentiment, but that general solution should be based around starting the agent "the right way", i.e. using systemd. It might be convenient for the coder Terraform provider to also be able to spit out a systemd unit like we currently have in the Digital Ocean template. |
Containers don't have systemd and neither does Windows or Mac, so I'm hesitant to say that's the right way. With that, the agent should run as the target user to maximize cross-platform compatibility, we don't require root privileges for anything. |
Well, the right way for linux. |
Interestingly, I tried VS Code Remote to the old Meaning: some other issue fixed by #2150 was breaking VS Code Remote on AWS. This is the kind of thing I'm talking about when I say that missing |
@kylecarbs , if you're dead set on adding a |
I think this isn't a great solution for our users. It's better than nothing so I won't hold it up, but I'd be much more in favor of defaulting a |
metadata_startup_script = <<EOMETA | ||
#!/usr/bin/env sh | ||
set -eux pipefail | ||
|
||
mkdir /root || true | ||
cat <<'EOCODER' > /root/coder_agent.sh | ||
${coder_agent.dev.init_script} | ||
EOCODER | ||
chmod +x /root/coder_agent.sh | ||
|
||
export HOME=/root | ||
/root/coder_agent.sh | ||
|
||
EOMETA |
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 believe you could just export HOME=/root && ${coder_agent.dev.init_script}
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 thought about that, but I want to move this template in the direction of writing scripts to disk in anticipation of further refinement where we also write a systemd unit.
To echo my perspective, every container-based deployment will have to manually set home, or they'll encounter these problems. |
Signed-off-by: Spike Curtis <spike@coder.com>
This is the first PR of #1386 but I still want to investigate the other cloud providers to see whether they hit a similar issue with $HOME before closing it.
This modifies the gcp-linux template to setup a home directory before running the agent script.