-
Notifications
You must be signed in to change notification settings - Fork 936
chore: fix agent tests on Windows 11 #17631
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1262,10 +1262,6 @@ func TestAgent_SSHConnectionLoginVars(t *testing.T) { | |
key: "LOGNAME", | ||
want: u.Username, | ||
}, | ||
{ | ||
key: "HOME", | ||
want: u.HomeDir, | ||
}, | ||
{ | ||
key: "SHELL", | ||
want: shell, | ||
|
@@ -1502,7 +1498,7 @@ func TestAgent_Lifecycle(t *testing.T) { | |
|
||
_, client, _, _, _ := setupAgent(t, agentsdk.Manifest{ | ||
Scripts: []codersdk.WorkspaceAgentScript{{ | ||
Script: "true", | ||
Script: "echo foo", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
||
Timeout: 30 * time.Second, | ||
RunOnStart: true, | ||
}}, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could we set HOME here instead?
coder/agent/agentssh/agentssh.go
Line 912 in df0c6ed
This is what OpenSSH does as well: https://github.com/openssh/openssh-portable/blob/7cc8e150d51a4545b86d996692b541419b35d1a3/session.c#L991
Almost added it last time I was excavating here but I opted on the side of caution. 😅
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.
We could, but then we'd be adding functionality AFAICT no one has asked for. I'd much prefer to reduce code than increase it.
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 would like to push back on this. We're not adding functionality, we're fixing a bug. If you try out SSH server on Windows, the HOME environment variable will be set when you SSH in. As such we're just matching expectations and bringing our product in line.
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.
@stirby punting to Product to make the call here. WDYT?
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.
It's my understanding here that
$HOME
on windows is taboo. However, OpenSSH sets this, so we're either going to match the expectations of Windows administrators or OpenSSH users?How does this fix a bug @mafredri? It sounds like adding functionality to satisfy this test.
It doesn't sound super compelling to keep this. I have no customer data suggesting one way or another.
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 would opt to cut it.
Uh oh!
There was an error while loading. Please reload this page.
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.
@stirby I can't say I'm deep enough in the know to know whether or not it's taboo, but if you're running SSH on Windows, you're doing so via OpenSSH server (Windows component), which means that
HOME
will be set. So whether or not the client is using OpenSSH or PuTTY or what have you,HOME
will be set. I was suggesting we would match this behavior as I consider its absence a bug. The OpenSSH implementation has always been our guiding light for our own SSH implementation, but if you see no value in it then let's drop it.Uh oh!
There was an error while loading. Please reload this page.
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'll just add that this is a very simple fix IMO, basically a one-line change (+ one relocation). Not sure why this would be classified as a feature.
(TBH I'd like to see this change irrespective of Windows implementation, just so we're guaranteed to set the env correctly and not be influenced by the outside environment.)
But if we don't do this, I'd at least like to see this change reverted so that we keep the
HOME
test (it must be set correctly on Linux/macOS), add an exception for Windows and an accompanying reason why where diverging from the OpenSSH implementation.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 Coder agent doesn't mess with the HOME environment variable on any platform. If it's set, then the logged in user will have it too, if not, then not. If we did what you are suggesting we'd be testing the environment and not the agent, which is not the point of these tests.
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.
Yes @spikecurtis, that's exactly the bug right there. We don't, but we should. Unless
HOME
is set, certain software may not work or behave correctly. So far we seem to have been lucky that no customer environment initializes withoutHOME
or aHOME
set to the wrong path, or perhaps customers have figured out how to fix it on their own. I do not want us to continue relying on luck and undefined behavior.See
man login
.