Commit Graph

85 Commits

Author SHA1 Message Date
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
Johan Schuijt-Li
ba5db40d9a Do not drop connection on TLS resumption when using client certificates
Summary: Set the proper context for sessions.

Reviewed By: liubov-dmitrieva

Differential Revision: D13258641

fbshipit-source-id: edd18d4abc8f5475e0d2ac8395dfc877b2dd5958
2018-12-04 08:30:07 -08:00
Stanislau Hlebik
f07155b402 mononoke: remove mononoke configs, use toml files
Summary:
Config repo proved to be tricky to understand and hard to use. Let's just use
toml files.

Reviewed By: farnz

Differential Revision: D13179926

fbshipit-source-id: 3a44ee08c37284cc4c189c74b5c369ce82651cc6
2018-12-04 03:52:26 -08:00
Lukas Piatkowski
14636545aa mononoke: pass CoreContext down to changesets
Reviewed By: StanislavGlebik

Differential Revision: D13277448

fbshipit-source-id: 6e9a8dac77af8ab991005d14f654e315c234fe44
2018-11-30 10:14:22 -08:00
Lukas Piatkowski
08db0a35eb mononoke: pass CoreContext down to bonsai-hg-mapping
Reviewed By: aslpavel

Differential Revision: D13277450

fbshipit-source-id: 97cfbd917b321727bb4d960c91a784787660eb5b
2018-11-30 10:14:22 -08:00
Stanislau Hlebik
af03216ee2 mononoke: admin command to build and read skiplist indexes
Summary:
Let's add a command that builds and reads a skiplist indexes. This indexes will
be used by getbundle wireproto request to decrease the latency and cpu usage.

Note that we are saving only the longest "jump" from the skiplist. This is done
in order to save space.

Reviewed By: jsgf

Differential Revision: D13169018

fbshipit-source-id: 4d654284b0c0d8a579444816781419ba6ad86baa
2018-11-29 08:19:30 -08:00
Stanislau Hlebik
402f03056d mononoke: use ChangesetFetcher in skiplist code
Summary:
Let's make it use the same ChangesetFethcer as getbundle already does. It will
be used in the next diffs

Reviewed By: lukaspiatkowski

Differential Revision: D13122344

fbshipit-source-id: 37eba612935a209098a245f4be0af3bc18c5787e
2018-11-29 08:19:29 -08:00
Stanislau Hlebik
631556ed0d mononoke: migrate skiplist to bonsai changesets
Summary:
Most of our revsets are already migrated, let's migrate skiplists as well since
we want to use them in getbundle requests.

Reviewed By: lukaspiatkowski

Differential Revision: D13083910

fbshipit-source-id: 4c3bc40ccff95c3231c76b9e920af5db31b80d01
2018-11-29 08:19:29 -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
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
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
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
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
Lukas Piatkowski
44ad7ef408 sql: add wait_for_myrouter async function that the client can chain on to wait for myrouter to startup
Summary:
As per the comments added - MyRouter setup is such that it starts inside a tupperware container together with the binary that will be using it. This means that by the time the binary wants to use the MyRouter connection the MyRouter instance might not be ready yet. In order to mitigate this effect the myrouter::Builder will attempt to make a "Select 1" query and retry it with a backoff for a max of 2 min or until the connection is actually established.

Unfortunately the `queries!` macro had to be moved inside the `macro` module in order to make it usable from inside `myrouter` module, see this: https://stackoverflow.com/questions/31103213/import-macro-from-parent-module

Reviewed By: farnz

Differential Revision: D10270464

fbshipit-source-id: 9cf6ad936a0cabd72967fb96796d4af3bab25822
2018-10-11 10:52:05 -07:00
Lukas Piatkowski
cad69fedd0 filenodes: use sqlfilenodes instead of dieselfilenodes; pass myrouter_port around
Reviewed By: farnz

Differential Revision: D10338868

fbshipit-source-id: 60734d9635df442691cad3637aebd5bc838e03ad
2018-10-11 10:52:05 -07:00
Lowik Chanussot
395b124f5d Make get_manifest_by_nodeid accept HgManifestId
Summary: Make get_manifest_by_nodeid accept HgManifestId and correct all calls to get_manifest_by_nodeid.

Reviewed By: StanislavGlebik

Differential Revision: D10298425

fbshipit-source-id: 932e2a896657575c8998e5151ae34a96c164e2b2
2018-10-11 06:50:16 -07:00
Lukas Piatkowski
1d69b1f884 mononoke: add a flag for --myrouter-port, ignore it for now
Summary:
The idea for rollout is to:
- first make sure that Mononoke doesn't crash when a --myrouter-port is provided
- then tupperware configs will be modified to include myrouter as a collocated proces on every host and the port of that myrouter instance will be provided via command line
- lastly land the change that actually talks to myrouter

Reviewed By: StanislavGlebik

Differential Revision: D10258251

fbshipit-source-id: ea9d461b401d41ef624304084014c2227968d33f
2018-10-09 10:21:04 -07:00
Anastasiya Zhyrkevich
c4f7fae0bb LFS test from hg client to Mononoke server, with large files through
Summary:
Test is failing, as Mononoke server lfs support is not implemented yet.
Integration test for commands from hg client to Mononoke server.

\s(re) lines are added as after auto-save, the test script is formatted, and delete spaces at the empty lines.
In order to keep such lines, \s(re) could be added
In comparison of such line, pattern \s(re) is deleted and not compared.
See to mononoke/tests/integration/third_party/hg_run_tests.py for more information about comparison of the output lines.

Reviewed By: StanislavGlebik

Differential Revision: D10089289

fbshipit-source-id: 2962e80d919c21801d08990be190f2574c48646d
2018-10-08 16:05:59 -07:00
Anastasiya Zhyrkevich
0f6bba1de0 PUT request upload to mononoke API
Summary:
PUT request upload to mononoke API
hg client sends a PUT request to store a file into blobstore during push supporting LFS

Upload file by alias is divied into 2 parts:
- Put alias : blobstore key
- Put blobstore_key: contents

Keep in mind, that file content is thrift encoded

host_address for batch request is from command line flags -H for host, -p for port

Reviewed By: StanislavGlebik

Differential Revision: D10026683

fbshipit-source-id: 6c2726c7fee2fb171582bdcf7ce86b22b0130660
2018-09-27 11:20:46 -07:00
Stanislau Hlebik
6fe120cd26 mononoke: add all cachelib cmdline args
Summary:
Previously cachelib cmdline args were added only to cmd line binaries, but not
to Mononoke this diff fixes it.

Reviewed By: farnz

Differential Revision: D10083899

fbshipit-source-id: 8febba96561c5ab9a61f60fafc7a7e56985dc038
2018-09-27 08:09:07 -07:00
Simon Farnsworth
1c3f40aaf5 Log a JSON blob to Scribe for every commit to Manifold repos
Summary:
JSON blobs let other users of Mononoke learn what they need to know
about commits. When we get a commit, log a JSON blob to Scribe that other users can pick up to learn what they want to know.

Because Scribe does not guarantee ordering, and can sometimes lose messages, each message includes enough data to allow a tailer that wants to know about all commits to follow backwards and detect lost messages (and thus fix them up locally). It's expected that tailers will either sample this data, or have their own state that they can use to detect missing commits.

Reviewed By: StanislavGlebik

Differential Revision: D9995985

fbshipit-source-id: 527b6b8e1ea7f5268ce4ce4490738e085eeeac72
2018-09-27 04:25:16 -07:00
Anastasiya Zhyrkevich
82a7261d1f batch method implementation for LFS Mononoke API server
Summary:
POST request mononoke_api/objects/batch  from hg client.

According to git-lfs protocol
https://github.com/git-lfs/git-lfs/tree/master/docs/api
https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md

In order to get url for uploading/downloading files, hg client is sending POST request mononoke_api/objects/batch of the following format.

This diff implements support for this POST request.

As an answer it returns json in the format required in git-lfs protocol (see link for more info).

Reviewed By: StanislavGlebik

Differential Revision: D9966691

fbshipit-source-id: 53bcbb4b455e61d9d344bfd9b5b6fb00bc201084
2018-09-24 11:07:13 -07:00
Anastasiya Zhyrkevich
f33ea55653 download mononoke api
Summary:
WIP

Mononoke API download  for lfs
support get request
curl http://127.0.0.1:8000/{repo_name}/lfs/download/{sha256}

Reviewed By: StanislavGlebik

Differential Revision: D9850413

fbshipit-source-id: 4d756679716893b2b9c8ee877433cd443df52285
2018-09-20 01:37:00 -07:00
Lukas Piatkowski
b68675f549 mononoke config: stop using "path" in manifold based repos
Summary:
The "path" in manifold blobrepo is used for logging, but it has been quite confusing with "fbsource" and "fbsource-pushrebase" to be logged in an identical way - both are "fbsource", because of the "path" config. Lets not use the "path" for logging, instead use the "reponame" from metaconfig repo.

In case we ever want to have two repos that are named the same (please don't) or have logging under a different name than "reponame" from config then we can add a proper optional "name" parameter, but for now we don't require this confusing feature.

Reviewed By: StanislavGlebik

Differential Revision: D9769514

fbshipit-source-id: 89f2291df90a7396749e127d8985dc12e61f4af4
2018-09-11 08:06:31 -07:00
Jeremy Fitzhardinge
82386b46f7 mononoke/apiserver: use err_downcast macros
Summary:
Use the err_downcast macros instead of manual downcasting. Doesn't make
a huge code-size difference in this case, but a little neater?

Reviewed By: kulshrax, fanzeyi

Differential Revision: D9405014

fbshipit-source-id: 170665f3ec3e78819c5c8a78d458636de253bb6f
2018-09-06 14:24:08 -07:00
Arun Kulshreshtha
2dc93d6a5f refactor actors to simple struct
Summary: While I was working on `actix-srserver`, I realized the current design of the API server is quite unnecessary. The "MononokeActor" and "MononokeRepoActor" are only returning futures without much CPU computation cost. So it don't need to be placed in a separate thread.

Reviewed By: jsgf

Differential Revision: D9472848

fbshipit-source-id: 618ec39c42d90717fa6985fee7d6308420962d3f
2018-08-31 14:07:17 -07:00
Zeyi Fan
300047c2fa add thrift client
Summary: Added a thrift client library and binary for Mononoke API Server that allows us to play with the API Server's thrift port.

Reviewed By: farnz

Differential Revision: D9110899

fbshipit-source-id: 603cc5e2b5e0419a73c9eccb35f8c95455ada9ce
2018-08-19 16:07:12 -07:00
Zeyi Fan
dcf0665484 add cat_file in thrift
Summary: Add `get_raw` in thrift part.

Reviewed By: StanislavGlebik

Differential Revision: D9094301

fbshipit-source-id: 23bbfa6fb653e07ca687ff8e21da8ae5fca3333e
2018-08-19 16:07:12 -07:00
Zeyi Fan
0fcfbda8b1 add fb303 thrift server
Summary: This commit adds a basic thrift server that responds to fb303 status check queries to Mononoke API Server.

Reviewed By: farnz

Differential Revision: D9092291

fbshipit-source-id: d1e4ddb280c252f549d40a0bb03d05afccbf73b8
2018-08-19 16:07:12 -07:00
Matthew Dippel
a3b9887ac6 Encoded url handling for is_ancestor queries
Summary: Adds proper url decoding for is_ancestor, so that special characters can be encoded in the url.

Reviewed By: kulshrax

Differential Revision: D9325467

fbshipit-source-id: d3ff60e004be8d254ea6f7288188adf54ab7ff5f
2018-08-15 11:31:55 -07:00
Pavel Aslanov
c7badc8b47 store bonsai changesets in bookmarks instead of hg changesets
Summary: - Use `ChangesetId` instead of `HgChangesetId` in `Bookmarks`

Reviewed By: StanislavGlebik

Differential Revision: D9333273

fbshipit-source-id: 96a4d585f9a0479b87556a5f05ae7a9692dd8926
2018-08-15 07:36:15 -07:00
Jeremy Fitzhardinge
cb8a7586cd mononoke-apiserver: install panic handler
Summary: Install the default panic handler for apiserver

Reviewed By: fanzeyi

Differential Revision: D9252395

fbshipit-source-id: fdc2b3e1cb85e42e02b2944d034b79fe5808f781
2018-08-09 16:21:28 -07:00
Simon Farnsworth
53a9245288 Add mechanism to configure cachelib process size shrinker
Summary:
We'll be running in Tupperware, and want to shrink when we get too
large to avoid OOM due to caches. Configure cachelib appropriately

Reviewed By: StanislavGlebik

Differential Revision: D8900371

fbshipit-source-id: 4f1f64c2508c64e4ce2d201e0a0e86446f84ffef
2018-08-07 11:37:37 -07:00
Simon Farnsworth
cc1454d333 Restore cachelib blob caching
Summary: Reverts D8989404 so that we're using cachelib again.

Reviewed By: jsgf

Differential Revision: D9036003

fbshipit-source-id: 9867a12b81369156ee2e6aa7a7f1c81a638185d6
2018-08-07 11:37:37 -07:00
Zeyi Fan
99cf377332 use tokio::runtime::TaskExecutor for some tasks
Summary: This fixes the `blocking` cannot run without threadpool error.

Reviewed By: farnz

Differential Revision: D9017757

fbshipit-source-id: 037fd6f30598f56a83c1dd91c9b8c4f3c8e413b3
2018-08-07 10:57:45 -07:00