-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Allow using custom transfer agents directly #2429
Conversation
If this is the right approach, I can add some tests. The goal is to be able to use rsync through a custom transfer agent, see #379 |
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.
Hey, this is clever. I suggested a different place to put the standalone custom transfer logic, but otherwise looks good 👍
For tests, I'd recommend looking at test/test-custom-transfers.sh
and test/cmd/lfstest-customadapter.go
for prior art.
tq/transfer_queue.go
Outdated
q.wait.Done() | ||
} | ||
var bRes *BatchResponse | ||
if q.manifest.standaloneTransferAgent != "" { |
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.
What do you think about moving this check into the Batch()
function? That way standaloneTransferAgent
just works for all tq.Batch()
callers.
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.
Indeed this could be moved in the Batch()
function, but I think it might be better to get rid of that method altogether. All it does is to check for len(objects) which is already checked in tq.Batch()
, and make a very simple call to tq.Batch
.. and it's used in a single place only.
What other callers do you think there would be?
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.
tq.Batch()
is currently also used in test/git-lfs-test-server-api/main.go
. I'm open to refactoring the tq
package, but I think it should happen separately from this PR.
EDIT: Also, I agree that tq.Batch()
is not necessary.
tq/transfer_queue.go
Outdated
objects := make([]*Transfer, 0, len(batch)) | ||
for _, object := range batch { | ||
objects = append(objects, &Transfer{ | ||
Name: object.Name, |
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.
Name
isn't used in the custom transfer adapter protocol and can probably be omitted.
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.
You are right, the name is not used in the protocol. Removed.
tq/transfer_queue.go
Outdated
Name: object.Name, | ||
Oid: object.Oid, | ||
Size: object.Size, | ||
Path: object.Path, |
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 wonder if batch.ToTransfers()
should just pass the Path
along too, so it could be used here.
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.
Looks much slimmer, but now the server receives also the Paths in the Batch API requests. I'll leave it like it is now.
I pushed an update, the test passes but not if I shut down the lfs server:
The error is this:
Where should I look to find where it tries to connect to the server? |
Some custom transfer agents figure out everything by themselves and don't need any authentication or transfer details from the API server. Added the `lfs.standalonetransferagent` config option for specifying which custom agent should be used directly.
This is mergeable IMO. Please have a look. |
I figured that I should not stop the server used by the test. Clarified a bit the documentation about the setup/shutdown methods. |
@aleb this looks great, and thanks for your contribution to LFS! I've schedule this to be released in 2.3.0. |
There is a minor problem when using a standalone custom-transfer agent. When pushing a branch to a remote, the git-lfs fails because it tries to connect to the inexistent remote server through HTTPS to check some locking thing. Before dying it suggests to run something like:
This solves the problem, but I was wondering if the check should even be made when using a standalone custom-transfer agent. Does it makes sense to deactivate it when |
I think it makes sense to deactivate this. The code you're looking for is here: Lines 124 to 127 in 76e82ac
|
PR-2429 has implemented a mechanism to unconditionally specify standalone custom transfer agents. This commit addresses two limitations, so that standalone custom transfer can be configured per remote. * Custom transfer agents may now be specified based on an URL prefix match on the API URL. * git-lfs passes the Git remote in the stage 1 initiation message. The standalone custom transfer agent can use it to determine the remote file location. One remote can, for example, point to a server that supports ssh login and use rsync. Another remote can point to GitHub. LFS works for both. Example Git config: ``` remote.github.url=... remote.origin.url=ssh://gitssh.example.com/git/some/repo lfs.customtransfer.rsync.path=git-lfs-rsync-agent lfs.https://gitssh.example.com/git/.standalonetransfer=rsync ``` The config assumes that `git-lfs-rsync-agent` determines the remote from the stage 1 init message and then inspecting `remote.origin.url` to infer the rsync host. <https://github.com/aleb/git-lfs-rsync-agent>, 2017-09-17, does not yet do that. [PR-2429] 09b7c53 'Allow using custom transfer agents directly', <git-lfs#2429>. CC: Alexandru Băluț <ab@daedalean.ai>
PR-2429 has implemented a mechanism to unconditionally specify standalone custom transfer agents. This commit addresses two limitations, so that standalone custom transfer can be configured per remote. * Custom transfer agents may now be specified based on an URL prefix match on the API URL. * git-lfs passes the Git remote in the stage 1 initiation message. The standalone custom transfer agent can use it to determine the remote file location. One remote can, for example, point to a server that supports ssh login and use rsync. Another remote can point to GitHub. LFS works for both. Example Git config: ``` remote.github.url=... remote.origin.url=ssh://gitssh.example.com/git/some/repo lfs.customtransfer.rsync.path=git-lfs-rsync-agent lfs.https://gitssh.example.com/git/.standalonetransfer=rsync ``` The config assumes that `git-lfs-rsync-agent` determines the remote from the stage 1 init message and then inspecting `remote.origin.url` to infer the rsync host. <https://github.com/aleb/git-lfs-rsync-agent>, 2017-09-17, does not yet do that. [PR-2429] 09b7c53 'Allow using custom transfer agents directly', <git-lfs#2429>. CC: Alexandru Băluț <ab@daedalean.ai> Signed-off-by: Steffen Prohaska <prohaska@zib.de>
PR-2429 has implemented a mechanism to unconditionally specify standalone custom transfer agents. This commit extends the mechanism to specify custom transfer agents based on an URL prefix match on the API URL. Together with the previous commit, which added the Git remote to the custom transfer stage 1 initiation message, standalone custom transfer can now be configured per remote. One remote can, for example, use Rsync transfer to an SSH server. Another remote can use standard LFS to GitHub. Example Git config: ``` remote.github.url=... remote.origin.url=ssh://gitssh.example.com/git/some/repo lfs.customtransfer.rsync.path=git-lfs-rsync-agent lfs.https://gitssh.example.com/git/.standalonetransferagent=rsync ``` The config assumes that `git-lfs-rsync-agent` determines the remote from the stage 1 init message and then inspecting `remote.origin.url` to infer the rsync host. <https://github.com/aleb/git-lfs-rsync-agent>, 2017-09-17, does not yet do that. [PR-2429] 09b7c53 'Allow using custom transfer agents directly', <git-lfs#2429>. CC: Alexandru Băluț <ab@daedalean.ai> Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Some custom transfer agents figure out everything by themselves and don't need
any authentication or transfer details from the API server.
Added the
lfs.standalonetransferagent
config option for specifying whichcustom agent should be used directly.