Commit Graph

1293 Commits

Author SHA1 Message Date
Stanislau Hlebik
769503de5e mononoke: log reponame in wireproto logger
Summary: This will help traffic replay to distinguish between different repos

Reviewed By: farnz

Differential Revision: D12922287

fbshipit-source-id: 6eed2a0eebceca0636512baa3ee885f5d9c95ccb
2018-11-06 03:03:25 -08:00
Simon Farnsworth
1818b9917f Make it possible to configure a sharded database
Summary:
Sharding filenodes by path should stop us knocking over databases -
make it configurable.

Reviewed By: StanislavGlebik

Differential Revision: D12894523

fbshipit-source-id: e27452f9b436842e1cb5e9e0968c1822f422b4c9
2018-11-05 10:28:40 -08:00
Simon Farnsworth
2ca140b86a Shard filenodes table across multiple databases
Summary:
We can already flatten a single XDB server with filenodes traffic, and
do if we start up a server instance without a warm memcache. This is only going
to get worse in the future.

Start the process of sharding across multiple servers. For now, we can only
deal with shard size == 1, but this code should be ready to handle shard sizes
greater than 1

Reviewed By: StanislavGlebik

Differential Revision: D12888927

fbshipit-source-id: 8e01694357c390837487fdb3710685fd09feaec0
2018-11-05 10:28:40 -08:00
Stanislau Hlebik
ab1c7572cd mononoke: do not panic in blobimport
Summary:
Panic is useless here. It produces huge stack trace which just contains the
main function and makes it harder to debug the actual problem.

Let's just exit in case of errors.

Reviewed By: farnz

Differential Revision: D12912198

fbshipit-source-id: 1faeacfb96765ce047a801f6b072112f10b50b7b
2018-11-03 06:16:53 -07:00
Wez Furlong
b0150038f8 mononoke: apiserver: augment /tree method with size and content sha1 fields
Summary:
This augments `/tree` to yields the size and content sha1 hash for the entries.
This is important for Eden and avoids additional round trips to the server.

The content hashing is the portion that I expect some push back on,
because it doesn't appear to be cached today and the implementation
here does a simplistic fetch and hash.  By doing this we hope to
squash out a potential later fetch of the entire contents when
buck build is run.

Differential Revision: D10865588

fbshipit-source-id: c020ef07b99d8a5e8b2f8f7b699bf15e750d60a5
2018-11-02 08:21:18 -07:00
Stanislau Hlebik
b9b87fb279 mononoke: graceful shutdown
Summary:
This diffs add a signal handler for SIGTERM signal. When it's received then a
terminate process flag is set to true. When this flag is set then no new client
connections will be accepted, and server waits until open connections finish.
The connections can take a long time, so ideally an external process should
sent SIGKILL after a timeout.

Note that this change also makes thrift server thread detached. The reason is
because making it gracefully stop is non-trivial, so for making it detached
should be fine

Reviewed By: farnz

Differential Revision: D12857453

fbshipit-source-id: 6a8f890ff529d74c21fc0c62e16951dd95a3f101
2018-11-02 05:57:30 -07:00
Lukas Piatkowski
d5d4633fde streaming_clone: fix wrong column names in SelectChunks query
Reviewed By: farnz

Differential Revision: D12881135

fbshipit-source-id: 65c4b3d22ffe2099c89907b447a713bad6371eaa
2018-11-01 06:00:20 -07:00
Stanislau Hlebik
449db419c0 mononoke: move hooks
Reviewed By: farnz

Differential Revision: D10867650

fbshipit-source-id: 253c7c0bd87504430481399e7dbfbe8445f25bbd
2018-11-01 04:51:36 -07:00
Anastasiya Zhyrkevich
fa18b025e4 Get parents without reconstructing file
Summary:
According to [blobimport logic](diffusion/FBS/browse/master/fbcode/scm/mononoke/cmdlib/src/blobimport_lib/changeset.rs;fd16808edd6e51c1d0b82f4812fe843e797025e0$163-164)  blobimport requests
for parents and node content

Previous implementation was reconstructing filenode to
current revidx for both cases: for getting raw_content and for getting parents.

New implementation avoid reconstruction of the file content to retrieve parents.

Reviewed By: quark-zju

Differential Revision: D12857440

fbshipit-source-id: e1118affe85647931dd551b9ca7be5297afe56ce
2018-10-31 11:37:59 -07:00
Stanislau Hlebik
281e157410 mononoke: fix test-hooks.t
Reviewed By: lukaspiatkowski, HarveyHunt

Differential Revision: D12863783

fbshipit-source-id: 64b283b15b78aa999b7ca643a209cfc94e8e5377
2018-10-31 10:30:19 -07:00
Stanislau Hlebik
693ed31eaa mononoke: make sure there is at most one commit between RC and PROD
Summary:
Add one more restriction to the config repo to make sure we don't forget to
move PROD bookmark

Reviewed By: HarveyHunt

Differential Revision: D12857619

fbshipit-source-id: c4b5e65f2d0b437aad77d8ccc4b4971b60020af4
2018-10-31 07:49:35 -07:00
Stanislau Hlebik
aac38dc828 mononoke: add separate rc and prod config
Summary:
Let's have separate config bookmarks for release candidate and prod.
That will let us customize shadow tier behaviour.

This diff also adds checking of config repo consistency. It requires that RC
bookmark is a descendant of a PROD bookmark. This topology makes it easy to see
what are the changes between PROD and RC, and verification prevents divergence of
configs i.e. sutiations when somebody updated a prod config but forget to
rebase rc config.

Reviewed By: HarveyHunt

Differential Revision: D12857131

fbshipit-source-id: b60d8f7af16e3d530e5edeb22145ec0bd473ffe4
2018-10-31 06:33:29 -07:00
Lukas Piatkowski
7bcdf468bd changesets: fix for parentless commits with MySql
Reviewed By: StanislavGlebik

Differential Revision: D12838643

fbshipit-source-id: f9750a1d244c7ac37ac4bb551a520262bacac669
2018-10-30 06:41:15 -07:00
Stanislau Hlebik
1b0b0066d1 mononoke: add context to the failed hook
Summary: Makes it easier to debug

Reviewed By: farnz

Differential Revision: D10869139

fbshipit-source-id: 000a39f53418e343307dd2009620d6a674235239
2018-10-29 15:49:16 -07:00
Stanislau Hlebik
b37ee8bd4a mononoke: fix integration tests
Reviewed By: quark-zju

Differential Revision: D12826248

fbshipit-source-id: 87e04e2a2fb5fbfa9a754b798a39098986b6428b
2018-10-29 11:41:42 -07:00
Stanislau Hlebik
d91a35afeb mononoke: add hash validation for gettreepack
Reviewed By: HarveyHunt

Differential Revision: D10853149

fbshipit-source-id: 9592ee09723c2976e5fe5d9f002f3c50feb1e0e0
2018-10-29 09:57:02 -07:00
Stanislau Hlebik
48329d18d0 mononoke: add hash validation for getfiles
Summary:
Let's add an option to validate the getfiles content that we return to users on
some percent of requests.

It'll increase the latency so let's not enabling that by default

Reviewed By: HarveyHunt

Differential Revision: D10558180

fbshipit-source-id: 2d7ec4dfe7b37b7b5541013278006278d1df68fa
2018-10-29 09:57:02 -07:00
Stanislau Hlebik
0d204ba3a8 mononoke: add wireproto logger
Reviewed By: HarveyHunt

Differential Revision: D10526999

fbshipit-source-id: 2e1cb8805983d15b81987792c54a4aafae103eac
2018-10-29 09:57:02 -07:00
Lukas Piatkowski
fc352b60fe mononoke: remove diesel from codebase
Reviewed By: StanislavGlebik

Differential Revision: D10512736

fbshipit-source-id: 9cd8d3abdc896a9e7b01aaec63ff69380efc4f0c
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
248922636a streaming_clone: convert from diesel to sql
Reviewed By: StanislavGlebik

Differential Revision: D10512738

fbshipit-source-id: 43343996dc864a0ce978f454ff41a22cf343fd99
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
744c909225 bookmarks: convert from diesel to sql
Reviewed By: StanislavGlebik

Differential Revision: D10512737

fbshipit-source-id: 7c2612c7799972a63d9865c77f1599f39da0c762
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
09ce2e03fe sql: allow not passing type of write query
Summary: This will enable doing queries like DELETE, UPDATE or REPLACE without listing all possibilites in the macros

Reviewed By: StanislavGlebik

Differential Revision: D10499501

fbshipit-source-id: 3e2ba433722bd34ffb5960840c509dc27cc9eb5d
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
64e722dba4 changeset: convert from diesel to sql
Reviewed By: StanislavGlebik

Differential Revision: D10491452

fbshipit-source-id: ec1dcecf09acfa29a236fb4eddf2250b2ea762be
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
aab7ca78ec sql: add support for WHERE foo IN (list) statements, add support for trailing commas
Reviewed By: StanislavGlebik

Differential Revision: D10483800

fbshipit-source-id: 8b2fedfb1c5270d14a2d0fbdd55c0be5ace3f4a7
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
4adfa5732b bonsai-hg-mapping: convert from diesel to sql
Reviewed By: StanislavGlebik

Differential Revision: D10483793

fbshipit-source-id: 0d76843e702d510fc655eed52a8c0a68b169d06c
2018-10-29 05:18:29 -07:00
Stanislau Hlebik
c0ad6637c3 mononoke: remove useless println
Reviewed By: Anastasiya-Zhyrkevich

Differential Revision: D10869138

fbshipit-source-id: 304a47d78a748c4e4338abef9940fc924de792e4
2018-10-29 02:36:20 -07:00
Wez Furlong
5c33e3da65 mononoke-api: print error reason if bookmark cannot be found
Summary:
troubleshooting startup problems is overly difficult without
printing more context, so print it.

Reviewed By: Anastasiya-Zhyrkevich

Differential Revision: D12814794

fbshipit-source-id: e815a6a93b4d1d3d03370b158f6fdc93edbc4ef5
2018-10-28 08:06:39 -07:00
Anastasiya Zhyrkevich
a7232825a8 new filename encoding blobimport fix on www
Summary:
Recently there was a change in core hg that changed the way we encode filenames - D9967059. However, it wasn't reflected in Mononoke blobimport code, so the job is constantly fails

This diff change the filename encoding process according to Mercurial

Encoding process is in 3 steps:
1. (Capital -> _lowercaseletter) + ( _ -> __).
If new file name is > 255, than go to step 2, otherwise exit
2. (Capital -> Capital) + (_ -> __)
if new filename is > 255, then got to step 3, otherwise exit
3. (Capitals -> Capitals) + (_ -> : )

Reviewed By: StanislavGlebik

Differential Revision: D10851634

fbshipit-source-id: 28b7503b2601729113326a18ede3e93c04572c6d
2018-10-25 07:32:53 -07:00
Anastasiya Zhyrkevich
99010fdb55 sha1 check for lfs
Summary:
On push from hg client, require sha1 check on any type of the upload

If data is provided, sha1 will be calculated from bytes [sha1 calculation place](https://fburl.com/noa99y37)
If LFSMetaData is provided, sha1 will be calculated by fetching the file from blobstore [fetching place](https://fburl.com/boj4s74f)

Reviewed By: StanislavGlebik

Differential Revision: D10509331

fbshipit-source-id: 216f59541b8adf8ab87026612e735ac1527e7cc2
2018-10-25 05:56:21 -07:00
Stanislau Hlebik
4ee6aa6c03 mononoke: memcache for bonsai_hg_mapping
Reviewed By: jsgf

Differential Revision: D10505523

fbshipit-source-id: 2e12b61d6f03215489322b09e65e766d0a252866
2018-10-25 02:08:53 -07:00
Stanislau Hlebik
b058eabc13 mononoke: memcache for changesets
Reviewed By: jsgf

Differential Revision: D10505048

fbshipit-source-id: 1a7accbce29b952a5c8dc99a985eb528d282ddef
2018-10-25 02:08:53 -07:00
Stanislau Hlebik
7b9d0fb5df mononoke: memcache for filenodes
Summary:
We have a problem with service upgrades/restarts because many servers start
sending too many requests to mysql db.

Let's add a memcache that will prevent that.

Reviewed By: jsgf

Differential Revision: D10488624

fbshipit-source-id: 4575d359bc269e29fe72b47d7f47cda22bf4acd7
2018-10-25 02:08:53 -07:00
Stanislau Hlebik
d72dff8d99 mononoke: fix tests
Summary:
1) fbamend was replaced with amend
2) Looks like test-hooks.t was printing incorrect hash

Reviewed By: lukaspiatkowski

Differential Revision: D10508709

fbshipit-source-id: fe11b2fd0f996edc92323e0b0a6882bdd71203fb
2018-10-23 11:13:31 -07:00
Harvey Hunt
cd626265bf mononoke: Display hash of commit that failed a hook
Summary:
Display the hash of the commit that didn't pass a hook,
which is a common occurrence in fbsource hooks using $HG_NODE.

I fixed up the tests, but test-hooks.t is broken from
the hg amend/fbamend fallout and also has some other issues. I tried to only add
the changes relevant to this commit.

Reviewed By: StanislavGlebik

Differential Revision: D10466395

fbshipit-source-id: dd1cdc994171a014c3d4806804ace14e85e726d4
2018-10-23 03:08:09 -07:00
Harvey Hunt
59e414668c mononoke: Rename hook tests
Summary: Rename hook tests to be consistent

Reviewed By: StanislavGlebik

Differential Revision: D10466396

fbshipit-source-id: 85da5938d59e1bd2b20f164b679ca44fdf7f0cf3
2018-10-23 02:46:41 -07:00
Lukas Piatkowski
fe6e5f056c sql_ext: add SqlConstructors trait to avoid copying the same sql code in Mononoke
Reviewed By: StanislavGlebik

Differential Revision: D10483792

fbshipit-source-id: ebae1d0fc7ff6ee750df8f0743824b326901466a
2018-10-22 10:20:47 -07:00
Anastasiya Zhyrkevich
262c4b8cfa lfs-url as a separate command line argument
Summary:
Background:
According to [git lfs protocol](https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md) HTTP POST "batch" request should return a link to
the look-aside server.

In our case Mononoke API server is a look-aside server, and process both "batch" request and "upload/download" requests.

So it need to return a link to itself.

New approach requests a separate lfs-url for "batch" request.

The previous approach requested attributes --http-host and --http-port to make a link to the instance of API server running.

Reviewed By: StanislavGlebik

Differential Revision: D10488586

fbshipit-source-id: ed9d78ee9bc78bdcec5eea813bd9aaa6e4590a5c
2018-10-22 09:11:16 -07:00
Anastasiya Zhyrkevich
e82dcdbc15 add new health check request
Summary:
For unification with commit cloud vip configuration apiserver should support the same health check api
Request needed for corp2prod

The same as : D10488369

Reviewed By: liubov-dmitrieva

Differential Revision: D10488494

fbshipit-source-id: 50b4024295c596342a8080474383de850bb7754a
2018-10-22 08:12:00 -07:00
Stanislau Hlebik
6cb08f46ef mononoke: limit_filesize hook
Reviewed By: farnz

Differential Revision: D10361931

fbshipit-source-id: 2d2ca13a3f021cbf05d85dc9898a3d797037d085
2018-10-22 05:22:20 -07:00
Stanislau Hlebik
eff25a9f20 mononoke: allow to set limit on the number of processed commits
Summary: Let's allow to set the number of commits processes by hook tailer.

Reviewed By: lukaspiatkowski

Differential Revision: D10361239

fbshipit-source-id: ced118d5dfca3c8aea65cb8a21f5b487f47628cd
2018-10-22 05:22:20 -07:00
Stanislau Hlebik
911c338e46 mononoke: use get_bonsai_bookmark in Mononoke
Summary:
Bookmarks point to Bonsai changesets. So previously we were fetching bonsai
changeset for a bookmark then converting it to hg changeset in `get_bookmark`
method, then converting it back to bonsai in `pushrebase.rs`.

This diff adds method `get_bonsai_bookmark()` that removes these useless
conversions.

Reviewed By: farnz

Differential Revision: D10427433

fbshipit-source-id: 1b15911fc5d77483b5a135a8d4484fccff23c774
2018-10-22 05:19:52 -07:00
Lukas Piatkowski
bf6c409298 hooks: add no_buck_managed_project_files
Reviewed By: StanislavGlebik

Differential Revision: D10452623

fbshipit-source-id: 053b9914e43b2842086ce76c1ad799a34e130643
2018-10-19 17:51:17 -07:00
Michael Bolin
b83240eb52 Put together a doc to explain the contracts of hooks in Mononoke.
Summary:
This is based on my reading of the source code, so I may have gotten things
wrong. Feel free to editorialize!

By putting this in a doc, hopefully it makes it easier for us to reason about
the API at a high level. Obviously it would be great if we could keep this up
to date going forward.

Reviewed By: StanislavGlebik

Differential Revision: D10340604

fbshipit-source-id: 9f3e82d234842e06c52f8a8b4440f8e06c487c0b
2018-10-19 11:49:56 -07:00
Pavel Aslanov
653a77a998 correctly handle case conflicting reenames
Summary:
Correctly handles case conflicting renames (only change in casing).
-  path can now be removed from `CaseConlictingTrie`
- `check_case_conflicts` operates on `BonsaiChangeset` in pushrebase logic

Reviewed By: StanislavGlebik

Differential Revision: D10447522

fbshipit-source-id: d5342e7aa48154debee123b38bf3168e3371baa6
2018-10-19 04:19:56 -07:00
Stanislau Hlebik
bba987bf19 mononoke: fix conflict_markers hook
Summary:
It was broken because it only matched conflict markers that were on the first
line. This diff fixes it by splitting the file content by \n first

Reviewed By: farnz

Differential Revision: D10447393

fbshipit-source-id: a2091f6bc43e8bb9a77c63536e749432d524bbff
2018-10-19 02:41:22 -07:00
Michael Bolin
82e2435704 Port gitattributes-textdirectives hook to Mononoke
Summary:
This hook is designed to prevent text directives in .gitattributes
from making it into the repo.

As noted in the integration test, our regex may be too loose,
but it's probably OK, in practice.

For better or worse, for now, we're just trying to maintain the
behavior of the existing hook (though perhaps the existing hook
would have been a bit stricter if it wren't written in Bash).

For easy reference, here are the Git docs on gitattributes:
https://git-scm.com/docs/gitattributes/

Reviewed By: StanislavGlebik

Differential Revision: D10387336

fbshipit-source-id: c58f689ecc0648c2cc359a818c92d701258e8f46
2018-10-19 00:50:00 -07:00
Simon Farnsworth
2d3bc65e05 Add a deny_files hook, like the one in Mercurial
Summary:
We want to deny landing files whose path contains magic strings. Add a
hook to do this, with some predefined examples of how to write patterns

Reviewed By: StanislavGlebik

Differential Revision: D10446531

fbshipit-source-id: 67f1a712d923345288c8d0a4f3e5da1e8f4e29f8
2018-10-18 13:32:00 -07:00
Lukas Piatkowski
9a23a6ceaf server: use the same tokio Runtime to load configs and to serve incoming requests
Summary:
Using multiple Runtimes might be a cause of problems in future and even if it isn't it will be a cause for investigating whether it is a problem or not.
The issue I have in mind is that if someone runs a future on one runtime that calls `tokio::spawn` on it (f.e. schedule a job that works for ever) but then uses a different runtime to drive another future to complection one might not suspect that the previous spawn is already lost with the previous Runtime.

Reviewed By: farnz

Differential Revision: D10446122

fbshipit-source-id: 4bfd2a04487a70355a26f821e6348f5223901c0d
2018-10-18 08:17:19 -07:00
Lukas Piatkowski
28bb85795e Back out "filenodes: revert using myrouter, use dieselfilenodes again"
Summary: Original commit changeset: 07da917455ae

Reviewed By: farnz

Differential Revision: D10446126

fbshipit-source-id: 918f77873cfb35744e489d9afb8b630764cbb199
2018-10-18 08:17:19 -07:00
Stanislau Hlebik
fb425906e0 mononoke: run hooks in parallel
Summary:
Previously buffered() wasn't particularly useful because it buffered only
mapping from ChangesetId to HgChangesetId. The actual running of hooks was done in
`.and_then()` and that means that each future in the stream should finish
before the next one starts.

Let's put running of hooks inside a buffer, that helps with perf a lot.

Reviewed By: jsgf

Differential Revision: D10359546

fbshipit-source-id: 48b8b200d7397eef8622c32cad9cec889b96f9d0
2018-10-17 08:06:06 -07:00