git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 7/5] transport: optionally honor DNS SRV records

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Mar 8, 2012, 16:18 UTC
Message-ID
<CABPQNSYpRGfu7Ew+KstCFsG4YDSx+i-jzHS1Bw0BA4S2hoz4SA@mail.gmail.com>
In-Reply-To
<20120308132155.GG9426@burratino>
On Thu, Mar 8, 2012 at 2:21 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 66 quoted lines
> Date: Mon, 6 Jun 2011 04:46:20 -0500
>
> SRV records are an extra layer of indirection on top of A/AAAA records
> mapping from domain names and service types to the hostnames of
> machines that offer that service.  That has a couple of nice effects:
>
>  - a single domain can use different hosts for different services
>  - a single domain can use multiple hosts for one service
>
> Teach git to perform a SRV lookup whenever resolving a git:// URL.
> This means:
>
>  - if your git server was previously the same machine as your wesnoth
>   server, you can move it to a separate machine without forcing
>   everyone to update their links to the old URLs
>
>  - if you have a primary git server and a backup machine that should
>   be used when the primary server goes down, the client can
>   automatically take care of it
>
>  - if you have multiple git servers and would like to spread load
>   between them, the client can automatically take care of it
>
> That is, SRV records let us ask the client to carry out various tasks
> that would require a proxy on the server side with traditional DNS.
> The client performs a SRV query to _git._tcp.<domain name> to receive
> its instructions.  RFC 2782 has details.
>
> Ideally reaping these benefits would just involve passing a special
> flag to getaddrinfo().  Since we don't live in such a world, this
> patch uses the BIND 8 API provided by libresolv to parse the response
> for ourselves.
>
> RFC 2782 requires some non-determinism in the order of hosts
> contacted; this patch uses drand48() for that.  To avoid causing
> trouble for platforms that lack the libbind ns_* functions or
> drand48(), the SRV support is only provided when requested by setting
> the USE_SRV_RR compile-time option.
>
> git servers must ensure that they can also be reached by a plain
> A/AAAA lookup to support git clients without SRV support, for example
> by proxying connections to an appropriate server:
>
>        # in inetd.conf
>        git stream tcp nowait.400 nobody /usr/sbin/tcpd \
>                /bin/nc -q0 gitserver.example.com git
>
> Regression: this uglifies error messages for connection errors a
> little.  It would probably be better to leave out the connection count
> when we are not trying more than one server.
>
> Based on a patch by Julien Cristau <jcristau@debian.org>.
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> As I mentioned at the gittogether, I think this would be a valuable
> feature in git.  You can test it out (though this is only the simple
> case, no load balancing or failover) by doing
>
>        git clone git://git.debian.org/~jrnieder-guest/git.git
>
> and watching what happens with wireshark.
>
> The patch needs documentation.  Maybe a howto and an addendum to the
> protocol docs would do.  Anyway, I hope it's at least entertaining in
> the current state.

It's an interesting feature, but I'm a little bit worried if this promotes non-portable setups; won't these repos be unreachable (at least without manually redirecting or also keeping a copy on the advertised URL) on machines where libresolv is unavailable? I'm mainly thinking about the "a single domain can use different hosts for different services"-benefit you mentioned. Multiple hosts for one service would probably be done by simply advertising one of the URLs, and get some load-balancing from the clients that DOES have libresolv...

Previous: Jonathan NiederNext: Jonathan Nieder
Message 12 of 20 in “transport: unify ipv4 and ipv6 code paths”
  1. 0/5 transport: unify ipv4 and ipv6 code pathsJonathan Nieder, Mar 8, 2012
  2. 1/5 transport: expose git_tcp_connect() and friends in new tcp.hJonathan Nieder, Mar 8, 2012
  3. Erik Faye-LundMar 8, 2012
  4. 2/5 daemon: make host resolution a separate functionJonathan Nieder, Mar 8, 2012
  5. 3/5 daemon: move locate_host() to tcp libJonathan Nieder, Mar 8, 2012
  6. 4/5 tcp: unify ipv4 and ipv6 code pathsJonathan Nieder, Mar 8, 2012
  7. Erik Faye-LundMar 8, 2012
  8. Jonathan NiederMar 8, 2012
  9. 5/5 daemon: check for errors retrieving IP addressJonathan Nieder, Mar 8, 2012
  10. 6/5 tcp: make dns_resolve() return an error codeJonathan Nieder, Mar 8, 2012
  11. 7/5 transport: optionally honor DNS SRV recordsJonathan Nieder, Mar 8, 2012
  12. Erik Faye-LundMar 8, 2012
  13. Jonathan NiederMar 8, 2012
  14. Johannes SixtMar 9, 2012
  15. Jonathan NiederMar 9, 2012
  16. 8/5 srv: tolerate broken DNS repliesJonathan Nieder, Mar 8, 2012
  17. Richard HartmannMar 8, 2012
  18. Erik Faye-LundJun 11, 2012
  19. Junio C HamanoJun 11, 2012
  20. Jonathan NiederJun 14, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.