Commit Graph

121 Commits

Author SHA1 Message Date
David Budischek
7b92ba7c25 Remove logging to scribe from blobrepo
Summary: See D14279065, this diff is simply to clean up the deprecated code

Reviewed By: StanislavGlebik

Differential Revision: D14279210

fbshipit-source-id: 10801fb04ad533a80bb7a2f9dcdf3ee5906aa68d
2019-03-12 04:50:45 -07:00
Lukas Piatkowski
03d11a0169 core context: pass username and ssh env vars inside core context
Summary: The username and ssh vars are both properties of request, so they fit nicely inside per request CoreContext. They will be used in verify_integrity hook.

Reviewed By: StanislavGlebik

Differential Revision: D14385840

fbshipit-source-id: 9fe3cb96ffa89d8b017c730e37ca9ea4124ede0c
2019-03-11 10:43:50 -07:00
Zeyi Fan
5a5868c5f1 cache content sha1 (and file size) in memory
Summary: This diff uses `cachelib` to cache content SHA1 (and file size) in memory.

Reviewed By: StanislavGlebik

Differential Revision: D14011572

fbshipit-source-id: 957c1ff5e3db2393dd613943a521e5950c361554
2019-02-28 14:53:57 -08:00
Arun Kulshreshtha
2c58d0616a Make history fetching depth configurable
Summary: Add an optional `depth` parameter to the `getfilehistory` endpoint, allowing the caller to specify the maximum number of history entries to fetch.

Differential Revision: D14222991

fbshipit-source-id: 8b28c9674e764f0098a9780f94ef2957ef117f09
2019-02-27 12:43:57 -08:00
Arun Kulshreshtha
f34d6babe3 Make history fetching depth configurable
Summary: Optionally specify a max depth for history fetching.

Reviewed By: StanislavGlebik

Differential Revision: D14218337

fbshipit-source-id: b6b92181172637e58a43bf61793257559915c7f1
2019-02-27 12:43:57 -08:00
Adam Simpkins
13f0f6f328 move methods from fb303.FacebookService to fb303_core.BaseService
Summary:
Move most of the fb303 methods from `fb303.FacebookService` to
`fb303_core.BaseService`.

A few methods have been left behind.  In most cases these are methods that are
either already deprecated or that we would like to deprecate in the future.

One important method that is not being moved as part of this diff is
`getStatus()`.  We do want to move this to `BaseService` in the future, but
doing so is a bit more challenging than the other methods, since it also uses
a custom enum that will need to be moved from `fb303.thrift` to
`fb303_core.thrift`.  In most languages this can be done relatively easily
by replacing it with a typedef in `fb303.thrift`.  Unfortunately the `py3`
thrift generator does not handle typedefs well, so more work will need to be
done to enable this for python3 thrift code.

Reviewed By: yfeldblum

Differential Revision: D13688965

fbshipit-source-id: 48d3d007ef6b63b4176cab753624813b7f9d6526
2019-02-27 11:31:30 -08:00
Arun Kulshreshtha
557f37d144 Add method to get file history
Summary: This diff adds a new `getfilehistory` endpoint to the API server that takes a filenode/path pair and returns a stream of JSON-encoded history entries (corresponding to `types::LooseHistoryEntry`) representing the full history of that filenode. (Note that the particular serialization format can be changed relatively easily in the future; for now I've chosen JSON for ease of debugging.)

Reviewed By: StanislavGlebik

Differential Revision: D14197233

fbshipit-source-id: 390f2e528f36fa3ec4b402e2fc3def0f2d529432
2019-02-26 10:02:03 -08:00
Arun Kulshreshtha
472d5cc11a Convert to Rust 2018
Summary: Convert the API Server to Rust 2018 edition.

Reviewed By: StanislavGlebik

Differential Revision: D14222621

fbshipit-source-id: 4afd8a57c415cfd5b5923d15cb2873a1c098f861
2019-02-26 10:02:03 -08:00
Arun Kulshreshtha
d3f0de6a02 Apply rustfix suggestions
Summary:
Apply rustfix suggestions by running the following command:

```
buck run //common/rust/tools/rustfix:rustfix -- --edition --edition-idioms -T //scm/mononoke/apiserver:apiserver
```

Reviewed By: StanislavGlebik

Differential Revision: D14222618

fbshipit-source-id: 034ac78cc907cf04b95d80c4ccf9033133cf835d
2019-02-26 10:02:03 -08:00
Arun Kulshreshtha
99e224d463 Remove outdated Cargo.toml
Summary: The Cargo.toml file for the API server appears to be from a very old prototype version. It is tiny and barely captures any of the current dependencies (many of which can't be built with Cargo anyway). Let's delete it since it's not adding any value.

Reviewed By: StanislavGlebik

Differential Revision: D14222619

fbshipit-source-id: c7ce625da859ae6fa85e787a6e92a2795c8420c5
2019-02-26 10:02:03 -08:00
Arun Kulshreshtha
59a7b49781 Reorganize URL parameter structs
Summary:
The main module of the API server is growing pretty large, since a new method and query parameters struct is required for each new HTTP endpoint added to the server. To make this manageable, let's restructure the code so that each handler function is paired with a params struct that contains its corresponding params.

This makes it easier to make changes to individual handlers, such as switching the method GET to a POST and changing the handler to read the params from the request body.

Reviewed By: StanislavGlebik

Differential Revision: D14222620

fbshipit-source-id: 67abea2ff32a3d6cc278375efd368fa2969ab891
2019-02-26 10:02:03 -08:00
Zeyi Fan
4294a5ea61 add manifest field to get_changeset method
Summary: This diff added "manifest" field to Mononoke API Server's `get_changeset` method, which is required to implement Eden's `BackingStore::getTreeForCommit`

Reviewed By: StanislavGlebik

Differential Revision: D13966576

fbshipit-source-id: d2444b3aab477ab76efa7baddf114d90fa7a7a77
2019-02-25 12:40:28 -08:00
Zeyi Fan
276b18b5ea add thrift method get_tree
Summary: Add a thrift method `get_tree` to Mononoke API Server

Reviewed By: StanislavGlebik

Differential Revision: D13964085

fbshipit-source-id: c0d31e4e13079bec49d480c116ebb300c7e4260f
2019-02-25 12:40:28 -08:00
Zeyi Fan
d9d33a341f add thrift method get_blob
Summary: Add a thrift method `get_blob` to Mononoke API Server.

Reviewed By: StanislavGlebik

Differential Revision: D13960835

fbshipit-source-id: 98ac78dae38837339b5666d46feac23540fa4b02
2019-02-25 12:40:28 -08:00
David Budischek
d0e230f54f Send ctx with request
Summary: This is needed to enable D14085659. Currently we do not have access to the core context when actually logging stuff. This change will not affect http api as Im not sure how to send the context to the middleware.

Reviewed By: StanislavGlebik

Differential Revision: D14081760

fbshipit-source-id: 6c3e8e1e7d153fbac62c842130e9caf51e5aac5a
2019-02-18 02:36:49 -08:00
Lukas Piatkowski
0d3b4e9301 mononoke args: use cmdlib::args to unify defining and parsing of --myrouter-port flag
Summary: use common funcions to parse --myrouter-port, this is a simple clean up

Reviewed By: StanislavGlebik

Differential Revision: D14084003

fbshipit-source-id: 63d6c8301e977faead62cb1c705bac372d56594e
2019-02-15 13:16:27 -08:00
David Budischek
79cbf5c245 post-commit send scribe message
Summary: New commits should be logged to scribe, these will be used to trigger the update for the hg clone streamfile.

Reviewed By: lukaspiatkowski

Differential Revision: D14022599

fbshipit-source-id: a8a68f12a8dc1e65663d1ccf1a5eafa54ca2daf0
2019-02-13 07:26:33 -08:00
Adam Simpkins
a4379a25f0 make fb303.FacebookService derive from fb303_core.BaseService
Summary:
Update the `fb303.FacebookService` type to derive from the new
`fb303_core.BaseService` definition.  This is in preparation to begin moving
most of the fb303 methods to `BaseService`.

Unfortunately the Rust thrift compiler does not handle service inheritance
very well, so all existing rust thrift servers need to be updated to handle
this change.

Reviewed By: wez

Differential Revision: D13683717

fbshipit-source-id: c6ba8dcbadd05d674b7a75ea531500268e4bc3f2
2019-02-11 17:28:30 -08:00
David Budischek
304b927dd8 Add flag to toggle skiplist population
Summary:
Populating skiplist at startup takes up to 3 minutes when not compiling in prod mode. This allows developers to turn this off and just use an empty skiplist (this only affects historical queries, and those can still be tested using recent commits)

The reason for negating the flag is to not hide core functionality behind a flag.

Reviewed By: StanislavGlebik

Differential Revision: D13986936

fbshipit-source-id: 053ecbd27aeeaa97f03194933e1d904a3e60ffcc
2019-02-11 08:59:29 -08:00
David Budischek
d844c21777 Thrift endpoint for is_ancestor
Summary:
I decided against using the naming convention maybe_ancestor and maybe_descendant as I believe the name is_ancestor already implies this uncertainty.

Skiplist is used instead of bfs, this improves performance significantly when using very old commits. For now we do not update skiplist as more recent commits are in cache anyway.

Reviewed By: StanislavGlebik

Differential Revision: D13917333

fbshipit-source-id: 21b49d920ff473c953a952ee3c6d7b55565f98ac
2019-02-08 03:31:09 -08:00
Lukas Piatkowski
c163368a07 blobrepo/src/file.rs: use HgFileNodeId instead of HgNodeHash and propagate it
Summary: HgFileNodeId is a stronger typed id, so it is prefered to use it instead of HgNodeHash whenever it is identifying a filenode

Reviewed By: aslpavel

Differential Revision: D13986172

fbshipit-source-id: c0334652345acb868e86c38b8c0045e9c023c176
2019-02-07 04:04:28 -08:00
Lukas Piatkowski
515a2909eb monononoke hashes: remove usages of borrows of hashes which are Copy
Summary: The Copy trait means that something is so cheap to copy that you don't even need to explicitly do `.clone()` on it. As it doesn't make much sense to pass &i64 it also doesn't make much sense to pass &<Something that is Copy>, so I have removed all the occurences of passing one of ouf hashes that are Copy.

Reviewed By: fanzeyi

Differential Revision: D13974622

fbshipit-source-id: 89efc1c1e29269cc2e77dcb124964265c344f519
2019-02-06 15:11:35 -08:00
Zeyi Fan
ef0272abca Convert thrift to failure
Summary: Migrate `rust-thrift` from `error-chain` to `failure`.

Reviewed By: Imxset21

Differential Revision: D13853559

fbshipit-source-id: 4bab8c544588265c85dee2f668ed47b8e97d321e
2019-02-06 10:34:10 -08:00
David Budischek
12e23f0772 improve apiserver logging
Summary:
Apiserver should log success and not rely on scmquery-proxy for that. Also did some refactoring:
1. cleaned up .timed methods in the thrift section
2. Moved the creation of ScubaSampleBuilder to one central location so common logging data doesnt have to be added to both http and thrift section

Reviewed By: StanislavGlebik

Differential Revision: D13895685

fbshipit-source-id: 3c6295e172f8ccaabaf38f436b304b5cb717deca
2019-02-06 01:38:11 -08:00
Stanislau Hlebik
0b0a5b93b2 mononoke: extract blobrepo_factory and postcommit from blobrepo
Summary:
`blobrepo_factory` is a crate that knows how to create blobrepo given
a configuration i.e. it creates blobstores, filenodes, changesets etc and
initializes blobrepo with them.

`post_commit` is a small part of blobrepo which can also be extracted from
blobrepo crate.

There are a few upsides with this approach
1) Less dependencies on Blobrepo, meaning we have to rebuild it fewer times
2) BlobRepo compilation is faster

Reviewed By: jsgf

Differential Revision: D13896334

fbshipit-source-id: 1f5701341f01fcefff4e5f9430ddc914b9496064
2019-02-05 01:23:15 -08:00
Arun Kulshreshtha
b5b0af79bc Add API server endpoint to serve HG file content
Summary: Add a `/getfile/` endpoint that takes a filenode and returns Mercurial file content. This is similar to the `/blob/` endpoint, except the returned content can also include copy information in the case that the file was copied. This matches the exact format in which Mercurial stores file content, so the resulting output can be directly written to disk.

Reviewed By: chadaustin

Differential Revision: D13876096

fbshipit-source-id: 0417cb1f993c4c93687e364b1647490c3a9040bc
2019-02-01 01:42:15 -08:00
David Budischek
e6e4c87a58 resolve bookmarks
Summary: Apiserver now resolves bookmarks to the correct hash.

Reviewed By: StanislavGlebik

Differential Revision: D13860603

fbshipit-source-id: 5f7eef407db01bdd3e89211f647704faec473991
2019-01-31 05:03:44 -08:00
David Budischek
b017b8eb94 Improved error handling for thrift apiserver
Summary:
At From<Error>::from errors are automatically downcast into an InternalError. While we unwrap them for http this was not done for thrift, resulting in an InternalError being returned for everything. By unwrapping the error first thrift now returns more meaningful errors.

In addition I added a new errorkind for ls_v2, this is purely for internal structure as the client will still see an InvalidInput error.

Reviewed By: StanislavGlebik

Differential Revision: D13881374

fbshipit-source-id: bd2e43a0ac7e5abdbf41068c3b1ab37681f03009
2019-01-31 05:03:44 -08:00
Stanislau Hlebik
a6f6f28564 mononoke: split reachability index
Summary:
Let's split reachability index crate. The main goal is to reduce compilation
time. Now crates like revsets will only depend on traits definition but not on
the actual implementation (skiplist of genbfs).

Reviewed By: lukaspiatkowski

Differential Revision: D13878403

fbshipit-source-id: 022eca50ac4bc7416e9fe5f3104f0a9a65195b26
2019-01-31 00:41:48 -08:00
Stanislau Hlebik
4d48415149 mononoke: split metaconfig crate
Summary:
Currently if a crate depends even on a single type from metaconfig then in
order to compile this trait buck first compiles metaconfig crate with all the
logic of parsing the configs.

This diff split metaconfig into two crates. The first one just holds the types for
"external consumption" by other crates. The second holds the parsing logic.

That makes builds faster

Reviewed By: jsgf, lukaspiatkowski

Differential Revision: D13877592

fbshipit-source-id: f353fb2d1737845bf1fa0de515ff8ef131020063
2019-01-31 00:41:48 -08:00
Stanislau Hlebik
a055f8e409 mononoke: move open_blobrepo to blobrepo crate and remove TestDelay blobrepo type
Summary:
The main reason to do it is to remove dependency from cmdlib to repo_client.
repo_client depends on a lot of other crates like bundle2-resolver, hooks etc.
And it means that in order to compile mononoke_admin we need to compile these
crates too. By moving open_blobrepo into blobrepo crate we are removing
unnecessary dependencies.

Also let's remove unused blobrepo type

Reviewed By: aslpavel

Differential Revision: D13848878

fbshipit-source-id: cd3d04354649cdb5b2947f08762051318725c781
2019-01-30 06:31:10 -08:00
David Budischek
6f68946a61 Implement UnionType for Revision in Thrift parameters
Summary: This is to take the guesswork out of revisions. MononokeRevision now states explicitely whether the value is a hash or bookmark. To roll this out I will prepare an updated scmquery-proxy version, test everything on shadow. Then use the sitevar to disable mononoke usage for a short time while both apisever and scmquery-proxy are rolled out simultaneously

Reviewed By: StanislavGlebik

Differential Revision: D13817040

fbshipit-source-id: d5eee7cf9ac972fb1313a10a17bf60c4545054af
2019-01-29 03:42:28 -08:00
David Budischek
ecc1d57b46 Add thrift implementation for list_directory
Summary: Corresponds to ls_v2 on scmquery

Reviewed By: StanislavGlebik

Differential Revision: D13817075

fbshipit-source-id: 56857076c85d7592d34a20a5fa303b33be2b4a20
2019-01-29 03:42:28 -08:00
David Budischek
2c40be3222 Add thrift endpoint for get_branches
Reviewed By: StanislavGlebik

Differential Revision: D13765974

fbshipit-source-id: 8c554ca85cde4838673fa6900a6b5643ee9a4973
2019-01-29 03:42:28 -08:00
David Budischek
da847be133 rustfmt apiserver
Summary: Ran rustfmt on the complete folder

Reviewed By: HarveyHunt

Differential Revision: D13803235

fbshipit-source-id: ccb41d7be8099055b8ea8dec57ce5e04b38b9461
2019-01-29 03:42:27 -08:00
David Budischek
bb4284e428 Add thrift support for get_commit_v2
Summary: Create the corresponding endpoint for thrift calls to get_commit_v2. For now this only supports the non optional fields.

Reviewed By: StanislavGlebik

Differential Revision: D13730602

fbshipit-source-id: fd9d845620c864bf7dade13d810e98270425ea00
2019-01-22 03:32:48 -08:00
David Budischek
58d812ec0f Enable logging for thrift calls to apiserver
Summary: Log all thrift calls to scuba. Since the params are in thrift format we log them both in json and human readable format (e.g. path is binary thus not really readable in json format). In addition both http and thrift now log the request type.

Reviewed By: StanislavGlebik

Differential Revision: D13730245

fbshipit-source-id: 3419ec067a9066e181210d184195fbd02980c1e0
2019-01-21 01:09:18 -08:00
Arun Kulshreshtha
6810d7d835 Change Arc<BlobRepo> to BlobRepo
Summary: `BlobRepo` is cheaply clonable and doesn't need to be `Arc`'d.

Reviewed By: StanislavGlebik

Differential Revision: D13726727

fbshipit-source-id: 0b983c7c4625f47df8a11da5781b7777cc38d72f
2019-01-18 11:37:37 -08:00
Adam Simpkins
d7eaf4e8d1 reformat several files
Summary:
Reformat several rust files with the current rustfmt, to make the linter
happy.

Reviewed By: yfeldblum

Differential Revision: D13683205

fbshipit-source-id: f7a02dae0fbe095b6acde4de380aca2acfedf39d
2019-01-16 11:47:37 -08:00
David Budischek
1d74d6da43 Fix healthcheck for apiserver thrift
Summary: Healthcheck broke because getStatusDetails wasnt implemented

Reviewed By: HarveyHunt

Differential Revision: D13671087

fbshipit-source-id: cc1182f16bbc719cbb95c3619e593a3514b02969
2019-01-15 07:52:50 -08:00
Lukas Piatkowski
b36dd037ad sqlblob: initial implementation of the sql based blobstore
Summary: MyRouter and cache support will come in next diffs

Reviewed By: StanislavGlebik

Differential Revision: D13465146

fbshipit-source-id: 0ede0e875d4a49794ff71173bd0d1563abb3ff08
2019-01-15 07:05:33 -08:00
David Budischek
9044d4d4d8 Fix apiserver thrift TARGETS file and add python exports
Summary:
We need to add python exports to our TARGETS file to enable scmquery
to create a ServiceRouter Client for mononoke-api

Reviewed By: StanislavGlebik

Differential Revision: D13651275

fbshipit-source-id: ba5a4eb3665dae1ea127f4ceb96c1ce62e1e4563
2019-01-14 08:31:35 -08:00
Jeremy Fitzhardinge
408e7665d9 mononoke: move RepositoryId into mononoke-types
Summary: There's nothing Mercurial-specific about identifying a repo. This also outright removes some dependencies on mercurial-types.

Reviewed By: StanislavGlebik

Differential Revision: D13512616

fbshipit-source-id: 4496a93a8d4e56cd6ca319dfd8effc71e694ff3e
2018-12-19 10:24:27 -08:00
Pavel Aslanov
eb75d48a95 correctly handle configurations with multiple blobstores
Summary: Correctly handle repository with multiple blobstores

Reviewed By: StanislavGlebik

Differential Revision: D13434206

fbshipit-source-id: f4ab70ec037deba150ed5c1ee8e53d23317b8e09
2018-12-18 06:55:56 -08:00
Pavel Aslanov
043b374bf1 make BlobstoreId configurable from repoconfig
Summary: Make `BlobstoreId` configurable from repoconfig

Reviewed By: StanislavGlebik

Differential Revision: D13376824

fbshipit-source-id: 45e1b45fb0fcba6de91374e3621c7bbb1b465544
2018-12-18 06:55:56 -08:00
Stanislau Hlebik
1781fa7ef4 mononoke: fix config usages for apiserver
Summary:
We've moved to the new config structure, I forgot to make the same changes to
apiserver

Reviewed By: lukaspiatkowski

Differential Revision: D13358407

fbshipit-source-id: cec81a21518cdb3c91dabb93e220d1ba3e25d02c
2018-12-06 08:56:06 -08:00
Johan Schuijt-Li
b2746d95a1 Add support for TLS ticket encryption based on internal seeds
Summary: Synchronise encryption keys between multiple hosts.

Reviewed By: kulshrax, mingtaoy

Differential Revision: D13296482

fbshipit-source-id: 5fdb1d818b9b9c90be0f3f69d3cc01ac05cbac77
2018-12-05 18:19:23 -08:00
Arun Kulshreshtha
ecd3daefe4 Remove env_logger
Summary:
`env_logger` was enabled in D12934682 to assist with debugging production TLS
issues with the Mononoke API server VIP. It turns out that this was actually
not neccesary due to the slog_stdlog crate. As such, remove env_logger from the
API server.

Reviewed By: StanislavGlebik

Differential Revision: D13328349

fbshipit-source-id: c5ed33d5afe96f4823ce637de892188e95c647fa
2018-12-05 11:53:18 -08:00
Stanislau Hlebik
706e98799b mononoke: support many blobstores in metaconfig
Summary: Restructure the configs so that we can specify more than one blobstore

Reviewed By: lukaspiatkowski

Differential Revision: D13234286

fbshipit-source-id: a98ede17921ed6148add570288ac23636b086398
2018-12-05 05:58:07 -08:00
Lukas Piatkowski
5d9a151d85 mononoke: pass CoreContext down to blobstore
Reviewed By: jsgf

Differential Revision: D13324220

fbshipit-source-id: af7a2a650338ea66e504ea0acae1d103af10f8e3
2018-12-04 11:40:15 -08:00