Commit Graph

1504 Commits

Author SHA1 Message Date
Simon Farnsworth
d47b9d8aee Support configuring a repo as read-only
Summary:
As part of our read path rollout, we want to block user error from
creating new commits that will confuse blobimport. Make it possible to
configure a read-only repo

Reviewed By: StanislavGlebik

Differential Revision: D12945024

fbshipit-source-id: 4265bf57f8adac7965117b710b8285bac483b8ee
2018-11-08 04:10:09 -08:00
Anastasiya Zhyrkevich
3919c0eb4c LFS verification tool
Summary:
Purpose:
- Sha256 alias link to file_content is a required part of LFS getfiles works correct.
LFS protocol uses SHA-256 to refer to the file content. Mononoke uses Blake2.
To support LFS in Mononoke we need to set up a link from SHA-256 hash of the content to blake2 of the content.
These links are called aliases.

- Aliases are uploading together with file content blobs.
But only for new push operations.
- If repo is blobimported from somewhere, we need to make sure, that all the links are in blobstore.
If repo was blobimported before aliases were added then it may miss aliases for some blobs.
- This tool can be used to
   - find if any aliases are missing
   - fill missing aliases.

Implementation:
- Run in repo.
- Iterate through all changesets.
- Go through all the file_content blobs in the changesets
- Verify/generate alias256 links to file_content blobs.

Mode supported:
- verify, count the number of errors and print to console
- generate, if blob is missing to add it to the blobstore

Reviewed By: StanislavGlebik

Differential Revision: D10461827

fbshipit-source-id: c2673c139e2f2991081c4024db7b85953d2c5e35
2018-11-08 03:41:40 -08:00
Walter Schulze
fb5393f77e add stats collection in ChangesetFetcher
Summary:
Added a get_stats() Hashmap<String, Box<Any>> method for all ChangesetFetchers.
The CachingChangesetFetcher now returns statistics for cache.misses: usize, cache.hits: usize, fetches.from.blobstore: usize and max.latency: Duration.

Reviewed By: StanislavGlebik

Differential Revision: D10852637

fbshipit-source-id: 34114fd94c47aa26ea525fcc4ff76ad60827bc71
2018-11-07 15:14:30 -08:00
Arun Kulshreshtha
ae7b8debd4 Remove /status endpoint
Summary: Now that Tupperware is using `/health_check`, there are no users of `/status`, so remove this endpoint.

Reviewed By: StanislavGlebik

Differential Revision: D12908785

fbshipit-source-id: be9bfae9453143a6f4b26f7fc6cbc68a3f1adc5c
2018-11-07 10:56:07 -08:00
Anastasiya Zhyrkevich
3170c13b38 retrieve host from HttpRequest headers
Summary:
Mononoke-apiserver now will parse http header in order to get "host" url.

Based on that Host url, batch request will return the link to the same host.

Requirement:
LFS protocol consists of two parts:
- "batch" request, GET request
  - HG client sends ids of the file it wants to download/upload
- API server should return valid url for downloading and uploading objects
"upload/download" request.
  - Actual upload/download of the file

This diff allows API Server to return the link to itself on "batch" request. So Hg client will go to API Server again for uploading and downloading files.

Reviewed By: kulshrax

Differential Revision: D12941635

fbshipit-source-id: e56453b0d6239daa3848c285a1df09a4a869f2c8
2018-11-07 02:56:22 -08:00
Jeremy Fitzhardinge
473f262c65 tp2/rust: update to rust-1.30.0
Summary:
rustc-1.30.0 tries to work out what the linker actually is from the name, and
gets confused because the script we pass it is actually gcc (or clang), but has
`ld` in the name. Update the command-line options to also pass
`-Zlinker-flavor=gcc` to override the linker flavor inference.

proc_macros are now stable. The `quote` crate has a dependency on the `proc_macro`
which is now a shared object as part of the rustc distribution, which means that things
using `quote` must have a runtime linkage with the rustc libraries. The Thrift `codegen`
binary is the main thing affected by this, and I've hacked around it by putting an
`LD_LIBRARY_PATH` in the Buck macros. Need to find a nicer fix though.

rustc 1.30 now implements `#[macro_export(local_inner_macros)]`, which has
strict semantics around namespaces and symbol hygiene, which doesn't work with
common/rust/sql's macros. Work around this for now by just exporting
everything.

Reviewed By: kulshrax

Differential Revision: D12811597

fbshipit-source-id: f18d12e6d99994876c29d3a6bd6ae43f1f37dd17
2018-11-06 16:17:18 -08:00
Arun Kulshreshtha
0944fa6551 Add env_logger so we can see log messages from other crates
Summary: We need more insight into what's happening inside of actix and tokio in order to debug operational issues with the API server. Unfortunately, this sort of low-level debug logs from libraries are not captured by slog. Since many of the API server's dependencies use `env_logger`, calling `env_logger::init()` in main will allow us to see the debug output from those libraries by specifying the `RUST_LOG` environment variable.

Reviewed By: HarveyHunt

Differential Revision: D12934682

fbshipit-source-id: 417201e509de66c3340c900a4914ea3a03a791fe
2018-11-06 10:09:03 -08:00
Stanislau Hlebik
c1743bed48 mononoke: add mem write version of bonsai-hg-mapping
Summary:
We'd like to make it so that it's possible to create BlobRepo that can only do
writes in memory. Main motivation for that is to speed up hg changeset
generation from bonsai changeset. We'd like to create all hg changesets
sequentially, but store all the blobs/db entries in memory. Then we can send
blobs to blobstore/rows to database in parallel.

At the moment we only memory-write blobstore, this diff adds the same for
bonsai hg mapping. Note that there is a method that returns all inserts in the
same order as they were made. This is necessary because we need to ensure that
ancestor parents are recorded before descendatns.

Reviewed By: farnz

Differential Revision: D10427432

fbshipit-source-id: a231c5b04734e6efeec207820d2a5b2dbef02d98
2018-11-06 04:11:51 -08:00
Simon Farnsworth
0e82cb3711 Advertise tree-only nature in our caps string
Summary:
We are a tree-only server; advertising this in our caps should ensure
that when we're source of truth at Facebook, anyone with pre-treemanifest
versions of Mercurial gets an insta-fail on connect, rather than a weird error
when they start exchanging data with us.

Reviewed By: HarveyHunt

Differential Revision: D12927232

fbshipit-source-id: 52c15c8a0f1842b6ca023f97228277d0fd9e8e38
2018-11-06 04:03:15 -08:00
Stanislau Hlebik
a5c4d15d89 mononoke: verify_reviewedby_info hook
Summary:
Quite a big hook that checks whether a commit is reviewed.
What makes it big are exceptions. They should all be covered with tests

Reviewed By: farnz

Differential Revision: D10467787

fbshipit-source-id: b9f439d540b64a5df8c8f131b3e7ba2924af4c29
2018-11-06 03:59:35 -08:00
Stanislau Hlebik
258a8a0a6a mononoke: add a function to extract Phabricator tag
Summary:
In our hooks we may need to get access to test plan, list of reviewers, summary etc.
Lua doesn't have regex, only patterns. So parsing this information in Lua is a bit tricky.
What's even worse is the fact that we can't add any unittests, so debugging and
fixing is harder. Instead let's add a rust function that would do it for us

Reviewed By: farnz

Differential Revision: D10461203

fbshipit-source-id: 328b76171d2c45ceaf5b2a1f5e1d0bd4c326c223
2018-11-06 03:59:35 -08:00
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