sapling/eden/scm/tests/test-clienttelemetry.t
Xavier Deguillard 472ec19699 clienttelemetry: add wantslfspointers
Summary:
Rolling out LFSv2 on fbsource is a bit complex. Initially, the intent was to
roll it out via a server-only config and send pointers to say 5% of the
clients. The big snag in this is that LFS pointers are stored in Memcache, and
thus, a client who wasn't supposed to use LFS may end up reading a pointer from
Memcache, and issuing a request to the LFS server. Thanks to the way Memcache
works, this may lead to an avalance effect where everyone is fetching LFS
blobs, even if the server rollout is at a small percentage.

There are several solutions to this, the first obvious one would be to simply
not use Memcache for pointers, but that also means a forced connection to the
server, and a higher latency, ie: not a very desireable situation. An
alternative would be to have a proper capability exchange at connection time,
but that's unfortunately not feasible today due to the need to support the old
Mercurial server. Long term this is definitively the approach we want to go to,
and depending on the exchanged capabilities, we can even imagine using
different memcache keys automatically.

For now, we can hack this up by re-using the only free-form channel that the
client has to the server: clienttelemetry. Mononoke can then use the passed in
information to decide on whether to send LFS pointers (or not). This
unfortunately means that the rollout will be entirely client-side driven. To alleviate
the issue of Memcache keys being shared between clients wanting LFS pointers
and the ones not wanting them, a different Memcache key space will be used.

Reviewed By: StanislavGlebik

Differential Revision: D21765065

fbshipit-source-id: aebda3c567a827342b2fa96d374a06a23ea0ca34
2020-05-28 14:16:35 -07:00

61 lines
1.7 KiB
Perl

#chg-compatible
$ configure dummyssh
$ enable clienttelemetry
$ setconfig clienttelemetry.announceremotehostname=true
set up the server repo
$ hg init server
$ cat >> server/.hg/hgrc << EOF
> [extensions]
> sampling=
> [sampling]
> filepath = $TESTTMP/sampling.txt
> key.clienttelemetry = client
> EOF
set up the local repo
$ hg clone 'ssh://user@dummy/server' local -q
$ cd local
$ hg pull
pulling from ssh://user@dummy/server
connected to * (glob)
no changes found
$ hg pull -q
$ hg pull --config clienttelemetry.announceremotehostname=False
pulling from ssh://user@dummy/server
no changes found
$ hg pull -q --config lfs.wantslfspointers=True
check telemetry
>>> import json
>>> with open("$TESTTMP/sampling.txt") as f:
... data = f.read()
>>> for record in data.strip("\0").split("\0"):
... parsedrecord = json.loads(record)
... for key in "command", "fullcommand", "wantslfspointers":
... print("%s: %s" % (key, parsedrecord["data"]["client_%s" % key]))
command: clone
fullcommand: clone 'ssh://user@dummy/server' local -q
wantslfspointers: False
command: pull
fullcommand: pull
wantslfspointers: False
command: pull
fullcommand: pull -q
wantslfspointers: False
command: pull
fullcommand: pull --config 'clienttelemetry.announceremotehostname=False'
wantslfspointers: False
command: pull
fullcommand: pull -q --config 'lfs.wantslfspointers=True'
wantslfspointers: True
check blackbox
$ hg blackbox --pattern '{"clienttelemetry": "_"}'
* [clienttelemetry] peer name: * (glob)
* [clienttelemetry] peer name: * (glob)
* [clienttelemetry] peer name: * (glob)
* [clienttelemetry] peer name: * (glob)