Commit Graph

1850 Commits

Author SHA1 Message Date
Stanislau Hlebik
9ee9bfad0a mononoke: check whitelists to see if connection is allowed
Differential Revision: D15164726

fbshipit-source-id: b959bfc3e901b40ff068077e09d8537b683e7b51
2019-05-21 12:25:32 -07:00
Stanislau Hlebik
aac6a6c835 mononoke: add security config
Summary:
The config will be used to whitelist connections with certain identities and
blacklist everything else.

Differential Revision: D15150921

fbshipit-source-id: e4090072ea6ba9714575fb8104d9f45e92c6fefb
2019-05-21 12:25:31 -07:00
Arun Kulshreshtha
79cb376a98 edenapi: make hg debughttp print real hostname of api server
Summary: Per title, `hg debughttp` now prints out the hostname that the API server reports rather than the hostname in the URL we used to connect to it. The reason for this is that if the API server is behind a VIP, we get the actual hostname rather than just the VIP URL.

Reviewed By: xavierd

Differential Revision: D15170618

fbshipit-source-id: 9af5480f9987d8ea9c914baf3b62a00ad88d1b32
2019-05-21 12:25:31 -07:00
Arun Kulshreshtha
570bedd182 Add hostname endpoint
Summary:
Given that users typically connect to the API server via a VIP, it is
often unclear which actual host we're connected to. As such, API server
responses should contain the actual hostname of the server.

As a first pass at adding this, let's add a simple endpoint that just returns
the hostname, which can be used to see which hosts the VIP is sending requests
to.

Reviewed By: xavierd

Differential Revision: D15168952

fbshipit-source-id: d6fee5716df975fa1588bbf069ad6e970a779b1e
2019-05-21 12:25:31 -07:00
Jeremy Fitzhardinge
dc7842f569 mononoke: make config parsing stricter
Summary:
Disallow unknown fields. They're generally the result of a mis-editing
a file and putting the config in the wrong place, or some incomplete refactor.

Reviewed By: StanislavGlebik

Differential Revision: D15168963

fbshipit-source-id: a9c9658378cda4866e44daf6e2c6bfbdfcdb9f84
2019-05-21 12:25:30 -07:00
Jeremy Fitzhardinge
dd5de99cc3 mononoke: add configlint to check Mononoke config sanity
Summary:
Currently this checks for:
- all referenced files are present
- they're well-formed toml
- all the required config keys are set, and no unknown ones are set
- blob storage and metadata db are both remote or local
- repo ids are not duplicated

Reviewed By: farnz

Differential Revision: D15068649

fbshipit-source-id: ace0e7bc52bf853ac42384c4346c3b73591312e4
2019-05-21 12:25:30 -07:00
Stanislau Hlebik
a8a5bf77c9 mononoke: bump clone timeout
Summary: Seems like 15 mins is not enough, let's bump it

Reviewed By: farnz

Differential Revision: D15154597

fbshipit-source-id: 78b8a43bbc95845719245f71ac85fd22336f3ed6
2019-05-21 12:25:30 -07:00
Zeyi (Rice) Fan
6a2d775dff fix file entry cache overwriting
Summary: The SHA1 cache mistakenly caching only by the node hash while it is possible to have multiple files that have the same node hash while different names. This will cause the server incorrectly returning incorrect entry from the cache.

Reviewed By: StanislavGlebik

Differential Revision: D15092963

fbshipit-source-id: 608be9f2b749d0b77687ad5cf2d76d56398a543d
2019-05-21 12:25:29 -07:00
Stanislau Hlebik
b42c5a2b66 mononoke: set bookmark for hooks and use it in verify_integrity
Summary:
At the moment verify integrity script blocks master commits that do not pass
the check. Non-master commits are not blocked even if they don't pass the check
(for example, if they don't have a valid reviewer), but verify_integrity hook
still logs them to scuba.

Mononoke's verify_integrity was enabled only on master, meaning that the hook
won't run on non-master commits at all, and we won't log non-master commits to scuba.
This diff fixes it.

Reviewed By: farnz

Differential Revision: D15146725

fbshipit-source-id: ab432fb2eccae0fbcc10755f5c8447964c490285
2019-05-21 12:25:29 -07:00
Thomas Orozco
72fbf818e7 mononoke: hg sync job: Prefetch Bundle Data
Summary:
This introduces prefetching in the hg sync job, which allows us to separate two logically separate steps, and buffer between them:

- Fetching bundle data from Manifold so it can be replayed in Mercurial (we call this "preparing"). This can happen out of order.
- Submitting the changes to Mercurial. This must happen sequentially.

The upshot is that we can fetch new data from Manifold while we wait for Mercurial to apply it, which should increase our throughput.

 ---

This required a bit of refactoring for the main loop here. The reason for that is that, currently, we heavily rely on closures to capture the `log_entry` so we can pass it to Scuba, etc.

That doesn't work if we want to have buffering, because there isn't a single scope that represents

Instead, every step of the stream has its own scope, so we need to pass the `log_entry` through the stream itself. We also need to track the log entry in errors as well (e.g. to report them to Scuba).

Reviewed By: ikostia

Differential Revision: D15146682

fbshipit-source-id: f83284571f6ca90cb621c621c5165f7fbafd81b5
2019-05-21 12:25:28 -07:00
Thomas Orozco
ae3662226c mononoke: hg sync job: Split out bundle processing in fetch + sync
Summary:
This separates out the bundle processing into two separate steps: preparing (fetching the data) and syncing (sending it to Mercurial).

The underlying goal here is to extract the 1st part into a buffered stream. Doing so will require a little further rework because we need to attach error handling to the stream (in loop mode) or future (in sync-one mode), which requires further refactoring. I'll do so in a separate diff.

Reviewed By: ikostia

Differential Revision: D15121738

fbshipit-source-id: e88d6d730d413e9c1939eefa72ec18799c8b13be
2019-05-21 12:25:28 -07:00
Thomas Orozco
477670a03c make tests more deterministic
Summary:
One of the tests for mononoke admin (which I introduced recently) appears to be flaky. Sometimes, output from stdout (the error that terminates the program) and stderr (logs emitted while the program runs) is flipped.

I suspect this is caused by buffering, so this patch flushes all output before writing the error (if there was one).

An alternative approach here might be to write the final error to stderr instead of stdosut (so everything goes to stderr). That feels cleaner, but it does change the interface a little bit, so I didn't take that approach just yet. That said, if nobody objects, I'm happy to pick that approach instead.

Reviewed By: farnz

Differential Revision: D15146392

fbshipit-source-id: 67481afd4802cb48d24d19052988be4a83433efd
2019-05-21 12:25:28 -07:00
Thomas Orozco
8f514219a1 Implement missing methods on CachedBookmarks
Summary:
I introduced several new methods on the Bookmarks trait in:

- D15097549
- D15081759
- D15097935

At the same time, Pavel introduced a new implementation of that trait in CachedBookmarks:

- D14928419

That broke the build, this fixes it.

Reviewed By: farnz

Differential Revision: D15124562

fbshipit-source-id: 61e49261c3dc5bb396883e69c29afa329d5df9ab
2019-05-21 12:25:27 -07:00
Kostia Balytskyi
5756e29d5b mononoke: stop using fastmanifest on servers in tests
Summary: Enabling it was a mistake as we can't enable it on our real hg servers.

Reviewed By: farnz

Differential Revision: D15122167

fbshipit-source-id: 5e28968354b7487bd9c965d8b3f23245f6bd265a
2019-05-21 12:25:26 -07:00
Kostia Balytskyi
0be31dfa00 mononoke: add support for batched sendunbundlereplay calls
Summary:
This is a tentative implementation of batching for the sync job.
It works by running a peer once per batch and just sending new bundle
metadata on stdin. When the batch capacity fills up, we kill the peer
and run a new one.

Reviewed By: StanislavGlebik

Differential Revision: D15063281

fbshipit-source-id: b681594c023973a165047198d490207e35a354b8
2019-05-21 12:25:26 -07:00
Stanislau Hlebik
8847d1b2a4 mononoke: add functions to merge bundles
Summary:
We might use it in the sync job to make sync job faster. Merging bundles allows
us to save on sql lock and opening/closing transactions

Reviewed By: ikostia

Differential Revision: D15080348

fbshipit-source-id: bf2e4ca3dd7ff8c399a3baa34ab542f67ea6efa9
2019-05-21 12:25:25 -07:00
Thomas Orozco
c224058b2e Support hg-sync-bundle remains --without-blobimport
Summary: This adds the ability to exclude blobimport entries when querying the count of remaining entries in the HG sync replay log.

Reviewed By: ikostia

Differential Revision: D15097549

fbshipit-source-id: ae1a9a31f51a044924fdebbdd219fff1e2b3d46a
2019-05-21 12:25:25 -07:00
Thomas Orozco
8daba8e8c3 Support hg-sync-bundle last-processed --skip-blobimport
Summary:
This introduces a new `--skip` flag in Mononoke admin under `hg-sync-bundle last-processed`. This will update the last-synced counter to the last blobimport that preceeds a log entry that is no a blobimport.

In other words, it makes it so that the last change to be processed is *not* a blobimport.

It will fail if:

- There is no valid log entry to jump ahead to (e.g. all the further log entries are blobimports).
- The current change to be processed is not a blobimport.
- The mutable counter was changed by someone else in the meantime.

Reviewed By: ikostia

Differential Revision: D15081759

fbshipit-source-id: 8465321b08d9c7b5bc97526400518bcf3ac77f13
2019-05-21 12:25:24 -07:00
Thomas Orozco
1a05aaa1b2 Support hg-sync-bundle verify
Summary: This adds a command in mononoke admin to verify the consistency of remaining bundles to sync -- i.e. whether all bundles are blobimports or all of them are not blobimports.

Reviewed By: ikostia

Differential Revision: D15097935

fbshipit-source-id: a0df221c38e84897213edf232972ba420977e9d3
2019-05-21 12:25:24 -07:00
Thomas Orozco
37c34af244 Introduce a test tool to write stub log entries
Summary:
Stanislau and Kostia mentioned that adding a few more commands for managing the HG sync job in the Mononoke Admin tool would be useful — in particular those commands should interact with the list of log entries and the last sync.

Notably, they were:

- Add support for skipping ahead any blobimport log entries.
- Add a verify command to check that all entries looking forward are consistent — i.e. they're either all blobimport or all non-blobimport.

However, as it stands, it's hard to test those in integration tests, because one can't easily generate stub data to exercise on the admin tool.

Notably, inserting data through the `sqlite3` database command line results in inconsistent values for the `reason` column that don't compare equal to those we query from the Rust side of things.

We could work around this by updating the Rust code to e.g. use LIKE instead of equality checks, but then we're updating the production code exclusively for the purpose of serving tests.

So, instead, this patch proposes introduces a lightweight command line  tool to use in tests that basically just inserts data into the bookmarks database, but from the Rust side of things.

Reviewed By: StanislavGlebik

Differential Revision: D15081758

fbshipit-source-id: 574739d2e19e6ce59d729f1aee73c368612fb92b
2019-05-21 12:25:23 -07:00
Thomas Orozco
ac4afd1f0b Fix SQLBookmarks name
Summary:
The code in admin/main.rs passes `bookmarks` as the name of the SQLBookmarks database, but other pieces of code (the server which writes this data, and the hg sync job that normally consumes it) use `books`.

This hasn't been a problem until now since no integration tests exist for the admin tool. This path mismatch was never exposed since in production we don't actually care about this name.

Reviewed By: ikostia, StanislavGlebik

Differential Revision: D15081757

fbshipit-source-id: c4fcd328568160023f3c15fa2ab7d77accf2ad68
2019-05-21 12:25:23 -07:00
Pavel Aslanov
3b6081a6f5 make it possible to enable bookmark cache from configs
Summary: Now it is possible to configure and enable/disable bookmark cache from configs

Reviewed By: StanislavGlebik

Differential Revision: D14952840

fbshipit-source-id: 3080f7ca4639da00d413a949547705ad480772f7
2019-05-21 12:25:22 -07:00
Pavel Aslanov
655c1122e4 write through bookmarks cache
Summary:
This diff adds caching layer for bookmarks. It only effects semantics of `list_by_prefix_maybe_stale`, other should methods should not be effected by this change.
- all requests to database issued by `list_by_prefix_maybe_stale` are cached for `ttl` time
- but if happened locally cache is purged and replaced to new one which will go through master replica

Reviewed By: StanislavGlebik

Differential Revision: D14928419

fbshipit-source-id: 30994f9c31f8063e8d6b2dd0a6afb06c067aa65a
2019-05-21 12:25:22 -07:00
Stanislau Hlebik
2f4a56df43 mononoke: more efficient ensure_paths_exists implementation
Summary:
Before this diff we always wrote to master even if paths already exist. This
diff changes it - first check in replica if paths are there, and only then
write to master

Reviewed By: farnz

Differential Revision: D15063307

fbshipit-source-id: 802839f340c9953c7f2812e77d81bc66917c5e77
2019-05-21 12:25:21 -07:00
Stanislau Hlebik
1d9039751a mononoke: add memcache leases
Summary:
Generating hg changesets might create too many connections to mysql. Let's
how many hg changesets generation we have in-flight

Reviewed By: lukaspiatkowski

Differential Revision: D15069236

fbshipit-source-id: 2b7265d1efa7d09458ed214bad7bc6f32bda8dbf
2019-05-21 12:25:21 -07:00
Stanislau Hlebik
2acbc38df7 mononoke: refactoring to make using memcache leases
Summary:
We'll start using memcache leases in the next diff, this diff refactors the
code to make it adding memcache leases simpler

Reviewed By: lukaspiatkowski

Differential Revision: D15069237

fbshipit-source-id: 875c398a3825d839b3453a9c77043edec496efa2
2019-05-21 12:25:20 -07:00
Pavel Aslanov
c1099d91e3 correctly mark all pushrebased changesets as public
Summary: Before this change we were only marking head of the pushrebase, this change fixes this problem and marks all reachable changesets as public

Reviewed By: StanislavGlebik

Differential Revision: D15063835

fbshipit-source-id: 2a360684fc01cec0f639c1789eff8150e5ba5ebb
2019-05-21 12:25:20 -07:00
Johan Schuijt-Li
e5a71ba10e repo_listener: start logging of client identities
Reviewed By: StanislavGlebik

Differential Revision: D15047850

fbshipit-source-id: 5aee0aa984e409a6bfed44c5c44df548ae3e5cb0
2019-05-21 12:25:19 -07:00
Johan Schuijt-Li
5e4a97cecc tests: provision fb identity in to testing certificates
Summary:
In order to do more complete tests around authentication we need to provide
fb identity in to our test certificates.

Reviewed By: StanislavGlebik

Differential Revision: D15046017

fbshipit-source-id: 3f3cd450425944a2970c6f02e7eb92a878076a05
2019-05-21 12:25:19 -07:00
Pavel Aslanov
a3f11e37f7 convert to rust-2018
Summary: - convert phases crate to rust-2018, in preparation for the next diff in a stack

Reviewed By: StanislavGlebik

Differential Revision: D14995610

fbshipit-source-id: 30327508cee5154a8a788e8c5a2f914f7ccacfec
2019-05-21 12:25:18 -07:00
Nick Terrell
24a12572b9 Update to zstd-1.4.x
Summary:
* Update to zstd-1.4.x
* Update to the latest zstd-rs

Reviewed By: Cyan4973

Differential Revision: D15040909

fbshipit-source-id: 938904d95ab8b1108d750d83602ee9c11c2c87b5
2019-05-21 12:25:18 -07:00
Stanislau Hlebik
a9ac9c0c20 mononoke: add logging of latency and depth to generate hg_from_bonsai
Summary:
Add more logging for generation of hg changesets from bonsai. We are interested
in depth (i.e. how many commits it had to generate), latency of the whole
request and latency of generation of a single hg changeset.

Reviewed By: ikostia

Differential Revision: D15046567

fbshipit-source-id: 1e9b0471fa5ed7df3d492c11bf230adc7ee0c1b8
2019-05-21 12:25:17 -07:00
Stanislau Hlebik
701a08a4c0 mononoke: include deleted files in the list of changed files
Summary: Turns out mercurial always includes deleted files

Reviewed By: farnz

Differential Revision: D15034961

fbshipit-source-id: 33e6ffe098b74a177346ff913d66d3ddf6e95eff
2019-05-21 12:25:17 -07:00
Thomas Orozco
178931cc02 mononoke: add obsmarkers to pushrebase output
Summary: Added obsmarkers to pushrebase output. This allows the client to hide commits that were rebased server-side, and check out the rebased commit.

Reviewed By: StanislavGlebik

Differential Revision: D14932842

fbshipit-source-id: f215791e86e32e6420e8bd6cd2bc25c251a7dba0
2019-05-21 12:25:17 -07:00
Thomas Orozco
8e4d9e32af mononoke: add support for encoding obsmarkers
Summary: This adds supporting in mononoke for encoding obsmarkers, according to Mercurial's V1 format for obsmarkers.

Reviewed By: StanislavGlebik

Differential Revision: D14932828

fbshipit-source-id: fe7283554c9cdcfdeb303e19b28af60d49c26722
2019-05-21 12:25:16 -07:00
Kostia Balytskyi
629bc92983 mononoke: enable fastmanifest for mononoke tests
Reviewed By: StanislavGlebik

Differential Revision: D15034167

fbshipit-source-id: 5c276c4eed4a61381b51a13ad126e749c8892d1c
2019-05-21 12:25:16 -07:00
Stanislau Hlebik
869367c565 mononoke: remove unused get_bookmarks
Reviewed By: farnz

Differential Revision: D15018616

fbshipit-source-id: 8e0374a61dbad531ac885a86e02efd9d5a9a9d40
2019-05-21 12:25:15 -07:00
Stanislau Hlebik
e7719effbc mononoke: ods log when hg was generated from bonsai
Reviewed By: jsgf

Differential Revision: D15018615

fbshipit-source-id: 6e33f039ba774cb5e397f753b718fd316ea8f347
2019-05-21 12:25:15 -07:00
Jeremy Fitzhardinge
89ae5651a4 rust/sql: add stats for connection creation and reuse
Reviewed By: StanislavGlebik

Differential Revision: D14988868

fbshipit-source-id: e64c4ab57726d1743d11312592ba06107fdb78f4
2019-05-21 12:25:15 -07:00
Jeremy Fitzhardinge
08fd9ce03b rust/sql: add LABEL to SqlConstructors
Summary:
Add a LABEL constant to the SqlConstructors trait to make it easier to identify
which table is being used, for stats and logging.

Reviewed By: HarveyHunt

Differential Revision: D13457488

fbshipit-source-id: a061a9582bc1783604f249d5b7dcede4b1e1d3c5
2019-05-21 12:25:14 -07:00
Zeyi (Rice) Fan
6bc1af095d update to Rust 1.34.0
Reviewed By: jsgf

Differential Revision: D14963608

fbshipit-source-id: 550d63cd10c52e8bcbb25137bc29811955da0b20
2019-05-21 12:25:14 -07:00
Stanislau Hlebik
af70f9698a mononoke: decrease the number of write connections
Summary: Following D14935155, let's decrease number of write connections as well

Reviewed By: ikostia

Differential Revision: D14973547

fbshipit-source-id: c344ecc568be26287e998b45b6988744cb5e0a09
2019-05-21 12:25:14 -07:00
Harvey Hunt
4aafa0fd57 mononoke: Allow the hook tailer to exclude specific changesets
Summary:
Add a new option that allows a comma separated list of changesets
that should be excluded by the hook tailer.

Also add an option that allows the hook_tailer to parse a file containing
changesets that it should ignore.

If both arguments are passed, the collection of excluded changesets are
merged.

This will be used by the conveyor node to provide better signal by ignoring known
hook failures caused by hg hook bugs.

Reviewed By: aslpavel

Differential Revision: D14894072

fbshipit-source-id: b488bb0bb5e05d7313005e04c55568dd4be5b770
2019-05-21 12:25:14 -07:00
Arun Kulshreshtha
af4f871457 edenapi: use DataEntry
Summary: Update the Eden API client and server to use the new DataEntry type for file content downloads.

Reviewed By: quark-zju

Differential Revision: D14907958

fbshipit-source-id: 8a7b1cbb54bdc119dda11179ff94d3efdb7e85c9
2019-05-21 12:25:13 -07:00
Stefan Filip
23c7ce1c79 types: remove deprecated Key.name() and Key.set_name()
Summary: Removing this function in favor of using Key.path

Reviewed By: quark-zju

Differential Revision: D14945331

fbshipit-source-id: 6b6bb70375629edf37b2b04a86545f18e15b33b4
2019-05-21 12:25:13 -07:00
Jeremy Fitzhardinge
f2d3b57771 mononoke/repoconfig: refactor write_files in tests
Reviewed By: aslpavel

Differential Revision: D14944355

fbshipit-source-id: 210f727928068ab60ef749e62d3d7eb044d7114d
2019-05-21 12:25:13 -07:00
Jeremy Fitzhardinge
3ecceb90a2 mononoke: convert main binary to Rust 2018
Reviewed By: StanislavGlebik

Differential Revision: D14884873

fbshipit-source-id: 52cf2f81037e9fd8b2f9d6fdfc2a603eaca41a19
2019-05-21 12:25:12 -07:00
Jeremy Fitzhardinge
9fa31e9145 mononoke: runhook: convert to Rust 2018
Reviewed By: StanislavGlebik

Differential Revision: D14862997

fbshipit-source-id: 58a29c4d626edf61bcbb066f3082e90ff2bac289
2019-05-21 12:25:12 -07:00
Jeremy Fitzhardinge
e97860a4d7 mononoke/blobstore factory: remove unused new_rocksdb_delayed, and unpub others
Summary:
`new_rocksdb_delayed` wasn't used at all, and the other
`new_files`/`rocksdb`/`sqlite` aren't used anywhere else, so make them private.

Reviewed By: StanislavGlebik

Differential Revision: D14862288

fbshipit-source-id: 41e02804fca37f4f27dddd53ee27e60b43798a99
2019-05-21 12:25:12 -07:00
Pavel Aslanov
7ca65d1da3 restrict bookmarks moves onty to allowed set of users
Summary: restrict bookmarks moves onty to allowed set of users

Reviewed By: farnz

Differential Revision: D14934606

fbshipit-source-id: d149824b4d3d6376dde6e855cac214e5fda89fac
2019-05-21 12:25:11 -07:00