Commit Graph

31 Commits

Author SHA1 Message Date
Zeyi Fan
826dae5364 use new Mononoke API Server for MononokeBackingStore
Summary: This commit changes MononokeBackingStore to use new APIs provided by Mononoke API Server.

Reviewed By: chadaustin

Differential Revision: D8882789

fbshipit-source-id: 0f06ca5f850af9fb52f1d593b9abd715a541488a
2018-07-26 10:09:32 -07:00
Zeyi Fan
2db6597e81 add get_changeset operation
Summary: This commit adds support for changeset information retriving at `/<repo>/changeset/<commit hash>`.

Reviewed By: StanislavGlebik

Differential Revision: D8880547

fbshipit-source-id: ed68c577316693e0c685c347405b5d344d1bc87e
2018-07-26 10:09:32 -07:00
Zeyi Fan
cc169fd7b0 add get_tree operation
Summary: This commit adds support for `/<repo>/tree/<treehash>` (retrieving tree content by hash) .

Reviewed By: StanislavGlebik

Differential Revision: D8870870

fbshipit-source-id: 8b3271c819e47d112a8b44097f626360a05540d1
2018-07-26 10:09:32 -07:00
Zeyi Fan
993ffb4d3f add get_blob_content support
Summary: This commit implements the `<repo>/blob/<blobhash>` API that Eden needs.

Reviewed By: StanislavGlebik

Differential Revision: D8870300

fbshipit-source-id: eca9dc434c8fb584dfba1542c5242fbee18e6619
2018-07-26 10:09:32 -07:00
Zeyi Fan
3bc3cecfe3 support ls operation
Summary: This commit adds support to ls operation that lists files in a folder at some commit.

Reviewed By: StanislavGlebik

Differential Revision: D8729389

fbshipit-source-id: cad6d02da075e94b5269cc18052a5a3916ddac86
2018-07-26 10:09:32 -07:00
Zeyi Fan
8ab482ea68 refactor error handling in apiserver
Summary: Refactor the error handling process. Stop using `.context` for adding context. Uses cause instead.

Reviewed By: StanislavGlebik

Differential Revision: D8963269

fbshipit-source-id: d7f18467f5dfa510beaa33657620c2856b45fd1f
2018-07-26 10:09:32 -07:00
Lukas Piatkowski
dec3e9a444 mononoke: backout cachelib integration for blob caching
Summary:
Back out "[mononoke] Switch to cachelib for blob caching"

Original commit changeset: 2549d85dfcba

Back out "[mononoke] Remove unused asyncmemo imports"

Original commit changeset: e34f8c34a3f6

Back out "mononoke: fix blobimport"

Original commit changeset: b540201b93f1

Reviewed By: StanislavGlebik

Differential Revision: D8989404

fbshipit-source-id: e4e7c629cb4dcf196aa56eb07a53a45f6008eb4e
2018-07-26 10:09:32 -07:00
Matthew Dippel
5485cbd867 Bookmark support for is_ancestor queries in the API server
Summary:
Added support for queries which use bookmark names in place of node hashes. This involved:
* Creating a method `string_to_bookmark_changeset_id`, which takes a string, treats it as a bookmark, and tries to find the corresponding changeset id in the repo.
* Modifying the `is_ancestor call` in `MononokeRepoActor` to try to interpret the query strings as bookmarks if they can't be interpretted as node hashes.
* Introducing the `cloned` crate from `//common/rust` into the API server to make the above methods cleaner.
* Modifying the integration test to add a bookmark to the test repo and attempt querying using the bookmark name.

Reviewed By: fanzeyi

Differential Revision: D8976793

fbshipit-source-id: 3a2b58cac0fb80ee18fad8529bd58af5b54f85ef
2018-07-26 10:09:31 -07:00
Zeyi Fan
6d074978a8 update actix & actix-web
Summary: Update actix and actix-web to the latest version

Reviewed By: sunshowers

Differential Revision: D8965698

fbshipit-source-id: 18324161c832ccce4d908799a703368cd615996c
2018-07-24 10:50:36 -07:00
Matthew Dippel
8504b1f00d Moved some functionality from GenerationBFS into a shared helpers.rs file.
Summary:
Moved two types of functionality to a shared 'helpers' file so that they can be used by other indexes:
* Getting the Generation number of a changeset. The BlobRepo method currently returns an Option<Generation> as the success type, so putting the combinator calls to get the underlying Generation or map to an Error as a separate method will help keep the code more readible, and allow this logic to be reused in other parts.
* Checking if a node exists in the repo. This wraps the changeset_exists method from BlobRepo and returns an error if it was false or an error itself, else success with a void item. This just helps with code readability, so it will be obvious if the result of a future is being used, or if its success is just a prereq for the rest of the operations.
* Convert a collection of HgChangesetId to a collection of (HgNodeHash, Generation). Again, will help with code readability in more complicated functions, since the combinators of this method are, in my opinion, cluttering up the other methods using this functionality and making them more difficult to follow.

Reviewed By: StanislavGlebik

Differential Revision: D8919874

fbshipit-source-id: fc6cdf6e3a1f0dfa73c74ec94f0abac4a7860794
2018-07-23 17:08:05 -07:00
Matthew Dippel
3fdda29376 Adding support for is_ancestor queries to the Mononoke API server
Summary:
Adding support to the Mononoke API server for naive is_ancestor queries using a BFS.

The API server now supports queries as:
Request URL: "{repo}/is_ancestor/{proposed_ancestor}/{proposed_descendent}"
 where the arguments in the URL are:
    - repo: the name of the repo to query reachability in
    - proposed_ancestor: a 20 byte hex encoded string representing a node hash
    - proposed_descendent: a 20 byte hex encoded string representing a node hash

Response: One of:
    - the string, "true", if 'proposed_ancestor' is an ancestor of 'proposed_descendent' in 'repo'.
    - the string, "false", if the above condition isn't satisfied.
    - an error if the query couldn't be performed

This involved adding:
- new enum values for the MononokeRepoQuery and MononokeRepoResponse structs for 'IsAncestor' queries and responses.
- a dependency on the 'mononoke/reachabilityindex' crate.
- a 'is_ancestor' function to the MononokeRepoActor struct, which delegates queries to a GenerationNumberBFS index.
- appropriate url handling to the server object in main
- New enums to the API server ErrorKind, and appropriate down casting from the ReachabilityIndex ErrorKind.
- Integration tests which made the test repo in test-apiserver.t have a few branches, and queries the API server for reachability of pairs of commits.

Reviewed By: fanzeyi

Differential Revision: D8844221

fbshipit-source-id: 1ba102fede378688243827850ff67aabc587a748
2018-07-23 09:23:07 -07:00
Simon Farnsworth
6b199e300e Allow users to configure the automatic cache shrinkers
Summary:
cachelib can shrink caches to avoid running into OOM, while still
giving as close to full-sized cache performance as possible. Make it possible
for Rust users of cachelib to request cache shrinking on low memory, while
choosing a strategy that suits them.

Reviewed By: Imxset21

Differential Revision: D8895814

fbshipit-source-id: ca4eb5b002c9ed922e7f7f56de002313a0d2303b
2018-07-21 13:37:14 -07:00
Simon Farnsworth
2d15681343 Switch to cachelib for blob caching
Summary:
Start deprecating AsyncMemo for caching purposes, by removing its use
as a blobstore cache.

Reviewed By: StanislavGlebik

Differential Revision: D8840496

fbshipit-source-id: 2549d85dfcba6647e9b0824ab55ab76165a17564
2018-07-21 13:37:14 -07:00
Zeyi Fan
f81cf6ddd7 split actor.rs
Summary: It really bugs me to have a file with many different things. It is time to split these into individual files. Hope this is not an overdesign.

Reviewed By: kulshrax

Differential Revision: D8862772

fbshipit-source-id: 91f211764e0ffe8a9fb127c3d2f7c9890e1ce0f4
2018-07-17 16:52:16 -07:00
Zeyi Fan
c96a4a682e refactor apiserver - move things around
Summary: This commit cleans up the code in the API Server, and move the logic of mononoke related operation to the `api` crate.

Reviewed By: kulshrax

Differential Revision: D8849200

fbshipit-source-id: 5a53c8db1f76661efebce8ebb79a327350059837
2018-07-17 16:52:16 -07:00
Zeyi Fan
32a0dec031 + [scmquery] renaming blob entrypoint
Summary: This commit renames `/blob/` to `/raw/`. This helps users to distinguish the proposed "get file content by hash" API from the original "get file content by path".

Reviewed By: kulshrax

Differential Revision: D8869635

fbshipit-source-id: 79d9cdaeb7e4e55b3d804d4530fb17835104cc32
2018-07-17 14:09:56 -07:00
Zeyi Fan
07f201f93b implement TLS & HTTP2 support
Summary:
This commit added three options to specify locations to SSL certificates so the API server will accept encrypted traffic.

Currently this only works in HTTP/1.1 due to a bug in HTTP/2 parsing in actix-web. Once they fixed the bug upstream we will be able to serve HTTP/2 traffic as well.

Reviewed By: jsgf

Differential Revision: D8703861

fbshipit-source-id: 0d4e68276013a8aeb6ee006e5175b8caeba767cb
2018-07-16 17:07:46 -07:00
Zeyi Fan
b9ca1809b2 add scuba to apiserver.tw & filter out /status request from scuba
Summary:
This commit:

* add `--with-scuba` to apiserver.tw so we collect scuba metrics in tw deployed jobs.
* disable scuba for `/status` as it adds too much noise in apiserver's scuba table.

Reviewed By: kulshrax

Differential Revision: D8848271

fbshipit-source-id: 2f9638bd7ccb44f8ae02172097ccc38b3818b0e4
2018-07-16 10:08:53 -07:00
Pulkit Goyal
fc880f518b Add Cargo.toml files to crates. (#7)
Summary:
This is a series of patches which adds Cargo.toml files to all the crates and tries to build them. There is individual patch for each crate which tells whether that crate build successfully right now using cargo or not, and if not, reason behind that.

Following are the reasons why the crates don't build:

  * failure_ext and netstring crates which are internal
  * error related to tokio_io, there might be an patched version of tokio_io internally
  * actix-web depends on httparse which uses nightly features

All the build is done using rustc version `rustc 1.27.0-dev`.
Pull Request resolved: https://github.com/facebookexperimental/mononoke/pull/7

Differential Revision: D8778746

Pulled By: jsgf

fbshipit-source-id: 927a7a20b1d5c9643869b26c0eab09e90048443e
2018-07-09 19:52:27 -07:00
Zeyi Fan
cc02bf8371 bridge stdlog to slog
Summary: This commit bridges messages logged via `log` crate to be forwarded to `slog` using `slog-stdlog` crate. This allows us to see debug messages printed from third party crates that are using `log` instead of `slog`.

Reviewed By: StanislavGlebik

Differential Revision: D8703996

fbshipit-source-id: f847b76a52c262eded4f576a5d9065574ff7e4dd
2018-07-05 11:07:08 -07:00
Zeyi Fan
c53f98dece add scuba for mononoke apiserver
Summary: This commit adds a scuba middleware for actix. It will automatically collects metrics from the request and the response.

Reviewed By: StanislavGlebik

Differential Revision: D8706387

fbshipit-source-id: 4dddad0d977d42718ce53e1e4fd7b771a1eda7df
2018-07-05 10:07:38 -07:00
Zeyi Fan
dfd3b3c9de split middlewares
Summary: This commit splits middleware.rs into mod middleware, and move logic of computing responsive to a separate trait so it can be shared.

Reviewed By: StanislavGlebik

Differential Revision: D8715657

fbshipit-source-id: cf06249d41b9fbe1a4a7500ed5e8024bbf376d3f
2018-07-05 10:07:38 -07:00
Stanislau Hlebik
bac5f5dcca mononoke apiserver: fix integration test
Summary:
We've recently added a flag in a config repo to enable or disable the repo.
Let's use it in apiserver as well.

P. S.
As I think about it now, it maybe worth filtering enabled/disabled flag in
RepoConfig

Reviewed By: lukaspiatkowski

Differential Revision: D8732450

fbshipit-source-id: 1cd59f5a91dec28efd1e2c122f2f1ea58ded6ac1
2018-07-04 08:53:34 -07:00
Rain ⁣
33d7591900 blobrepo: turn manifold connection arguments into a struct
Summary:
There are so many individual arguments here that it's honestly hard to keep
track.

It is unfortunate that a bunch of string copies have to be done, but not really
a big deal.

Reviewed By: jsgf

Differential Revision: D8675237

fbshipit-source-id: 6a333d01579532a0a88c3e26b2db86b46cf45955
2018-06-28 11:46:06 -07:00
Zeyi Fan
e924f7f105 Change file content retrieval API to /<changeset>/<path>
Summary: This commit changes the API from directly asking for NodeHash to changeset id and path of the file.

Reviewed By: StanislavGlebik

Differential Revision: D8628826

fbshipit-source-id: 1fa37cf36db0ca00530f3a60de78da1d1d232398
2018-06-27 17:52:35 -07:00
Zeyi Fan
5c838efe54 Reorganize code structures
Summary: This commit implements a `Responder` for `MononokeRepoResponse` so it can be used as the return type of an actix-web handler. So the only need to be done to write a handler that accepts a `MononokeRepoQuery` is to assembly the struct.

Reviewed By: StanislavGlebik

Differential Revision: D8630086

fbshipit-source-id: 782252072f5fbb692f3ce0387370c8aaa48f4396
2018-06-27 17:52:34 -07:00
Zeyi Fan
6ef23f3646 Add /status for Tupperware health check
Summary: This commit adds /status to return ok for Tupperware health check.

Reviewed By: kulshrax

Differential Revision: D8629282

fbshipit-source-id: 8f36bf73d4d9399721c68649e6b475362770889b
2018-06-27 16:47:50 -07:00
Zeyi Fan
528b2bf36f Read filecontent from blobstore
Summary: This commit implements the retrieving logic for the api server.

Reviewed By: StanislavGlebik

Differential Revision: D8507784

fbshipit-source-id: 109b7fad35c5fefca593d04ac63d57534f9bd12b
2018-06-27 13:05:55 -07:00
Stanislau Hlebik
531986e5da mononoke: rename *test_manifold to *_manifold
Summary: It's no longer test, we use it in prod

Reviewed By: farnz

Differential Revision: D8611639

fbshipit-source-id: dc52e0bcdc26c704c0d9cf820d7aa5deae3e06e4
2018-06-25 07:51:20 -07:00
Zeyi Fan
eba437040d let apiserver read mononoke config
Summary: This commit lets apiserver reads Mononoke's config repository and creates MononokeRepo based on it.

Reviewed By: kulshrax

Differential Revision: D8465574

fbshipit-source-id: 0af1ad5f62499f83261e21bac605725156fc22d0
2018-06-22 15:36:44 -07:00
Zeyi Fan
1c4af3bda8 Create initial binary for Mononoke API Server
Summary: This revision adds an initial binary target for Mononoke API Server as well as a few basic options and logging.

Reviewed By: kulshrax

Differential Revision: D8413745

fbshipit-source-id: 65523433284e970348efcafd724ae28102d85671
2018-06-18 10:09:43 -07:00