-
Notifications
You must be signed in to change notification settings - Fork 2.2k
ssh: disable concurrent transfers if no multiplexing #5136
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
chrisd8088
left a comment
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 only had a few notes, and I notice the Windows CI jobs seems to be failing, so maybe that's something worth review as well (but perhaps it's not related to this PR)?
In our SSH code, we check if the error is non-nil and then enable multiplexing. However, this is backwards: only if the error is nil do we have a valid path and can we enable multiplexing. Fix this condition properly. Since our tests will now often get additional arguments, update lfs-ssh-echo to handle them gracefully.
Right now, we try to spawn multiple SSH connections using ControlMaster when making multiple requests. However, if multiplexing is not enabled, we can spawn multiple actual connections, which can be expensive and require lots of authentication requests. Instead, let's make sure we don't enable multiple connections if multiplexing is not enabled, since this may cause the user to be prompted for multiple SSH key connection attempts (say, if they're using a security key) and is substantially more heavyweight than simply spawning a new process over the same connection. Since the code has different behaviour if `XDG_RUNTIME_DIR` is set, make sure to unset it for the tests so that we always try to create a temporary directory and don't otherwise fail because that environment variable points somewhere unexpected.
|
Okay, the test failure has magically disappeared, I've added tests (and some additional commits since I discovered a bug), and this should be ready for another review when that's convenient. |
chrisd8088
left a comment
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.
This looks great, thanks!
In commit b44cbe4 of PR git-lfs#5136 the "multiplex" argument was added to the FormatArgs() function in our ssh/ssh.go source file. Later, the "controlPath" argument was also added, in commit 448b0c4 of PR git-lfs#5537. Neither of these arguments is used in the function's body, though, so we can remove them now.
In commit b44cbe4 of PR git-lfs#5136 the "multiplex" argument was added to the FormatArgs() function in our ssh/ssh.go source file. Later, the "controlPath" argument was also added, in commit 448b0c4 of PR git-lfs#5537. Neither of these arguments is used in the function's body, though, so we can remove them now.
In commit b44cbe4 of PR git-lfs#5136 the "multiplex" argument was added to the FormatArgs() function in our ssh/ssh.go source file. Later, the "controlPath" argument was also added, in commit 448b0c4 of PR git-lfs#5537. Neither of these arguments is used in the function's body, though, so we can remove them now.
In commit b44cbe4 of PR git-lfs#5136 the "multiplex" argument was added to the FormatArgs() function in our ssh/ssh.go source file. Later, the "controlPath" argument was also added, in commit 448b0c4 of PR git-lfs#5537. Neither of these arguments is used in the function's body, though, so we can remove them now.
In commit b44cbe4 of PR git-lfs#5136 the "multiplex" argument was added to the FormatArgs() function in our ssh/ssh.go source file. Later, the "controlPath" argument was also added, in commit 448b0c4 of PR git-lfs#5537. Neither of these arguments is used in the function's body, though, so we can remove them now.
In commit b44cbe4 of PR git-lfs#5136 the "multiplex" argument was added to the FormatArgs() function in our ssh/ssh.go source file. Later, the "controlPath" argument was also added, in commit 448b0c4 of PR git-lfs#5537. Neither of these arguments is used in the function's body, though, so we can remove them now.
Right now, we try to spawn multiple SSH connections using ControlMaster when making multiple requests. However, if multiplexing is not enabled, we can spawn multiple actual connections, which can be expensive and require lots of authentication requests.
Instead, let's make sure we don't enable multiple connections if multiplexing is not enabled, since this may cause the user to be prompted for multiple SSH key connection attempts (say, if they're using a security key) and is substantially more heavyweight than simply spawning a new process over the same connection.
Fixes #5064