Skip to content
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

Merged
merged 1 commit into from
Jul 31, 2017
Merged

Conversation

aleb
Copy link
Contributor

@aleb aleb commented Jul 20, 2017

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.

@aleb
Copy link
Contributor Author

aleb commented Jul 20, 2017

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

Copy link
Contributor

@technoweenie technoweenie left a 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.

q.wait.Done()
}
var bRes *BatchResponse
if q.manifest.standaloneTransferAgent != "" {
Copy link
Contributor

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.

Copy link
Contributor Author

@aleb aleb Jul 24, 2017

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?

Copy link
Contributor

@technoweenie technoweenie Jul 24, 2017

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.

objects := make([]*Transfer, 0, len(batch))
for _, object := range batch {
objects = append(objects, &Transfer{
Name: object.Name,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Name: object.Name,
Oid: object.Oid,
Size: object.Size,
Path: object.Path,
Copy link
Contributor

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.

Copy link
Contributor Author

@aleb aleb Jul 24, 2017

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.

@aleb
Copy link
Contributor Author

aleb commented Jul 27, 2017

I pushed an update, the test passes but not if I shut down the lfs server:

  # make sure git-lfs does not interact with the server when a standalone
  # transfer agent is set.
  curl -s "$(cat "$LFS_URL_FILE")/shutdown"

The error is this:

    17:08:06.236406 git.c:322               trace: built-in: git 'push' 'origin' 'master'
    17:08:06.237605 run-command.c:626       trace: run_command: 'git-remote-http' 'origin' 'http://127.0.0.1:61154/test-custom-transfer-standalone'
    fatal: unable to access 'http://127.0.0.1:61154/test-custom-transfer-standalone/': Failed to connect to 127.0.0.1 port 61154: Connection refused

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.
@aleb
Copy link
Contributor Author

aleb commented Jul 31, 2017

This is mergeable IMO. Please have a look.

@aleb
Copy link
Contributor Author

aleb commented Jul 31, 2017

I figured that I should not stop the server used by the test. Clarified a bit the documentation about the setup/shutdown methods.

@ttaylorr ttaylorr merged commit f0d355f into git-lfs:master Jul 31, 2017
@ttaylorr
Copy link
Contributor

@aleb this looks great, and thanks for your contribution to LFS! I've schedule this to be released in 2.3.0.

@ttaylorr ttaylorr added this to the v2.3.0 milestone Jul 31, 2017
@aleb
Copy link
Contributor Author

aleb commented Aug 9, 2017

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:

git config --replace-all lfs.https://SERVER/.locksverify false 

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 lfs.standalonetransferagent is set?

@ttaylorr
Copy link
Contributor

ttaylorr commented Aug 9, 2017

Does it makes sense to deactivate it when lfs.standalonetransferagent is set?

I think it makes sense to deactivate this. The code you're looking for is here:

state := getVerifyStateFor(endpoint)
if state == verifyStateDisabled {
return
}

sprohaska added a commit to sprohaska/git-lfs that referenced this pull request Sep 17, 2017
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>
sprohaska added a commit to sprohaska/git-lfs that referenced this pull request Sep 17, 2017
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>
sprohaska added a commit to sprohaska/git-lfs that referenced this pull request Sep 20, 2017
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>
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.

3 participants