Commit Graph

202 Commits

Author SHA1 Message Date
Rain ⁣
fb192f8f6f cmds/admin: init_cachelib before bonsai-fetch
Summary: There's a hidden dependency here -- ideally it'd be made explicit.

Reviewed By: jsgf

Differential Revision: D9307939

fbshipit-source-id: e00a201e20bb8d83be09eab10cfdd2ce03a3e22f
2018-08-13 16:52:25 -07:00
Tim Fox
a82b90c6f9 Implement hook tailer
Summary:
This diff implements a service which tails a configurable bookmark and runs hooks against it.
It uses the standard Mononoke config from the meta config repo.

Reviewed By: StanislavGlebik

Differential Revision: D8898637

fbshipit-source-id: f710fe4c9bda1b78bd17eb6cd6abf2abda4fdb8e
2018-08-08 05:36:13 -07:00
Simon Farnsworth
3733848cef Use Abomonation and cachelib to replace Asyncmemo
Summary:
Asyncmemo has two issues for our use:

1. Separate memory pool from cachelib caches.
2. Future fusion means that a `get` that should succeed will fail because there
was an earlier get still in progress.

The second is good for memoization, where the worst case from a failed get is
extra CPU work, but not so good for caching. Replace uses of Asyncmemo for
caches with a cachelib based cache

Reviewed By: StanislavGlebik

Differential Revision: D9013679

fbshipit-source-id: b85d4eec7294e0c8ee08faa671d26901b35cf1fc
2018-08-07 13:37:09 -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
Stanislau Hlebik
f3e5d4100a mononoke: add bonsai-fetch to admin
Summary:
Since we have bonsai changesets now, let's add a subcommand to print bonsai
changesets given an hg changeset

Reviewed By: farnz

Differential Revision: D9179315

fbshipit-source-id: fad8a7454b45608482ac9fbf0dae9be16d5cbd69
2018-08-07 06:22:01 -07:00
Stanislau Hlebik
9abd29d4c3 mononoke: use ChangesetId in Changesets
Summary:
Alas, the diff is huge. One thing is changing Changesets to use ChangesetId.
This is actually quite straightforward. But in order to do this we need to
adapt our test fixtures to also use bonsai changesets. Modifying existing test
fixtures to work with bonsai changesets is very tricky. Besides, existing test
fixtures is a big pile of tech debt anyway, so I used this chance to get rid of
them.

Now test fixtures use `generate_new_fixtures` binary to generate an actual Rust
code that creates a BlobRepo. This Rust code creates a bonsai changeset, that
is converted to hg changeset later.
In many cases it results in the same hg hashes as in old test fixtures.
However, there are a couple of cases where the hashes are different:
1) In the case of merge we are generating different hashes because of different
changed file list (lukaspiatkowski, aslpavel, is it expected?). this is the case for test
fixtures like merge_even, merge_uneven and so on.
2) Old test fixtures used flat manifest hashes while new test fixtures are tree
manifest only.

Reviewed By: jsgf

Differential Revision: D9132296

fbshipit-source-id: 5c4effd8d56dfc0bca13c924683c19665e7bed31
2018-08-06 10:36:43 -07:00
Tim Fox
8c7e623e3f Implement reading of file contents in file hooks
Summary:
This diff gets the machinery in place to allow file hooks to access file content. It uses the manifest vfs crate to do this.

Initially we just expose a simple contains_string() method which checks if the file content contains the given string (this is the most common thing file hooks want to do with content), but we can extend this with further methods as the need arises.

Reviewed By: StanislavGlebik

Differential Revision: D8889837

fbshipit-source-id: fb5191d6d1286f070a99108782ff529914aeb198
2018-08-06 07:52:19 -07:00
Jeremy Fitzhardinge
23fdf4b4f7 tp2: rust-1.28.0 update
Summary: update to Rust release 1.28

Reviewed By: farnz

Differential Revision: D9150356

fbshipit-source-id: 3dd237cfadc9ca1e9b0586d628a0ce4718df505b
2018-08-03 13:50:53 -07:00
Rain ⁣
06f619717f blobrepo_utils: rename BonsaiVerify to BonsaiMFVerify etc
Summary: This verifier works on manifests -- we'll need other ones for filenodes etc.

Reviewed By: StanislavGlebik

Differential Revision: D9105976

fbshipit-source-id: 939b72b6a3f69b716385315f69a57e91d71a45f3
2018-08-02 12:37:02 -07:00
Lucas Waye
2b21e28790 fetch file content by bookmark
Summary: The content-fetch subcommand will try to lookup a changeset by bookmark first and then falls back to a hash.

Reviewed By: StanislavGlebik

Differential Revision: D9110531

fbshipit-source-id: 3bd0e452739fc1c8b41dc559864f73e3a1f3f782
2018-08-02 07:53:18 -07:00
Rain ⁣
58ca0b1c3f bonsai-verify: add a way to weaken checks for merge commits older than a date
Summary: This is a workaround for buggy commits produced by older versions of treemanifest.

Reviewed By: farnz

Differential Revision: D9018502

fbshipit-source-id: 71f2aeeaee01500a1a73814dc9c4979ef2c79746
2018-07-29 21:21:33 -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
Rain ⁣
b42e67a0ed tool to verify bonsai changeset roundtripping
Summary:
The goal of this tool is to verify that bonsai changesets roundtrip with the same hashes. This uses the `ChangesetVisitor` stuff introduced in the previous diff to walk over a specific number of changesets.

I've been using this tool for a few days, and it's shaken out a number of bugs in the Bonsai support in Mononoke, and even found old bugs in Mercurial. So it's been a pretty useful exercise overall.

Reviewed By: farnz

Differential Revision: D8817725

fbshipit-source-id: b6976e8ff9024098c695e82383d98d95b2701e1b
2018-07-23 23:53:10 -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
Rain ⁣
6f65d1778f make the default style for most cli tools glog
Summary:
I don't like glog for interactive use at all. But keep it as the
default for blobimport, and add a flag to change it.

Reviewed By: StanislavGlebik

Differential Revision: D8909674

fbshipit-source-id: d0b9c439f72f231c95e9109e16b30e87cfaa2eed
2018-07-20 11:37:36 -07:00
Lukas Piatkowski
f728e8bb3f admin: add config fbpkg subcommand
Summary:
This command will create a PROD bookmark on the currently checked out commit of the choosen mononoke-config repo, then import it into a temp directory and finally invoke fbpkg build to create a package with that imported content.
It also calls fbpkg build inside the mononoke-config repo so that the VCS info from mercurial is persisted in fbpkg metadata.

Reviewed By: farnz

Differential Revision: D8907916

fbshipit-source-id: ee1843bf23c9bffe524d2b20c7322f84825e2663
2018-07-19 04:08:34 -07:00
Lukas Piatkowski
844337d523 admin: add config import subcommand
Summary: make it easier to import mononoke-config repo, can be used in development, but it also will be used in fbpkg in further diffs

Reviewed By: farnz

Differential Revision: D8887356

fbshipit-source-id: 6dbcccff7fedc6a72be1b8240e49d4fba8cf89a1
2018-07-19 04:08:34 -07:00
Lukas Piatkowski
339975884c blobimport: extract importing part of this command to a reusable library
Summary: later this library will be used by admin tool to ease importing of config repo

Reviewed By: StanislavGlebik

Differential Revision: D8882178

fbshipit-source-id: 293a26b038f8d76e9fcedb72a4041a48f502a00a
2018-07-19 04:08:34 -07:00
Lukas Piatkowski
26b0f52cef admin: add config clone subcommand
Summary:
can be used to easily clone mononoke-config and required hgrc setup
later this subcomand will be used to blobimport the mononok-config as well

Reviewed By: StanislavGlebik

Differential Revision: D8879500

fbshipit-source-id: 1ad19441bce73f5a8c56f5aebd04f331ca49519a
2018-07-19 04:08:34 -07:00
Stanislau Hlebik
08dd810568 mononoke: use ChangesetMetadata
Summary: Let's pass just one field instead of 4

Reviewed By: farnz

Differential Revision: D8889899

fbshipit-source-id: 8b30496a86950ed534439f5469f8740ee32345b8
2018-07-18 04:21:42 -07:00
Lukas Piatkowski
d672bb6c68 hooks: replace tokio_core with tokio::runtime
Reviewed By: farnz

Differential Revision: D8867126

fbshipit-source-id: fe66e5f56c0d627a9b626e904262252e25cf45ba
2018-07-17 04:54:59 -07:00
Lukas Piatkowski
24dc56c8a3 manifoldblob: remove usages of tokio_core
Summary: tokio::runtime can handle multithreading, no need for all this bolierplate

Reviewed By: StanislavGlebik

Differential Revision: D8861170

fbshipit-source-id: 2c489068a55f8cba1854f8a748df1e6efe8b47b7
2018-07-17 04:54:58 -07:00
Lukas Piatkowski
a274c622b8 blobimport: replace usage of tokio_core with tokio::run
Summary:
There seems to be a deadlock in the internals of the now outdated tokio_core.
After applying the modern tokio::run the deadlock is not being triggered.

Reviewed By: farnz

Differential Revision: D8783183

fbshipit-source-id: 47a7d1d8e2756ea4d40812d0b8a6c850d7f7e9f8
2018-07-16 07:36:54 -07:00
Pavel Aslanov
6a77477d4d added BonsaiHgMapping to BlobRepo
Summary: Makes `BonsaiHgMaping` accessible from `BlobRepo` object

Reviewed By: StanislavGlebik

Differential Revision: D8821709

fbshipit-source-id: 03070ac4f9f390b76740c5d493f5a86b14024158
2018-07-13 08:03:13 -07:00
Rain ⁣
5a29953c59 cmds: move creating blobrepo to cmdlib
Summary: This will be useful for the bonsai verification tool.

Reviewed By: StanislavGlebik

Differential Revision: D8792562

fbshipit-source-id: f409d0fa042528b04462a1539fd3c2a8064a4f6e
2018-07-11 18:36:50 -07:00
Rain ⁣
3f476a9b16 cmds: move getting the repo id to cmdlib
Summary: This code can easily be shared.

Reviewed By: StanislavGlebik

Differential Revision: D8777307

fbshipit-source-id: f11314f6a63bb191dc38d07cec181a4b05b158d9
2018-07-11 18:36:50 -07:00
Simon Farnsworth
d40a725f7b Refactor MemcacheBlobstore to split into common and memcache parts
Summary:
When we add cachelib bindings to Rust, we're going to want to implement a
cachelib blobstore that's more or less the same as the memcache version, but
backed by a cachelib pool instead of a memcache instance.

Split this code up so that we don't duplicate functionality

Reviewed By: StanislavGlebik

Differential Revision: D8523713

fbshipit-source-id: 882298abab8c208103f6d8c74fee60a768c877f6
2018-07-10 10:10:18 -07:00
Tim Fox
7f55aad570 Use the Bookmark struct to represent bookmarks instead of string
Summary: This diff refactors the hook code to use the Bookmark struct instead of strings

Reviewed By: farnz

Differential Revision: D8724197

fbshipit-source-id: 920aa1266ca94b2bd8683a995e4fd781159bd5b1
2018-07-05 03:22:52 -07:00
Tim Fox
c6009ab467 Implement Lua per file hooks
Summary:
This diff extends lua hooks to support per file hooks.

We also now call the hook function via a Lua wrapper function which allows us to have a better API in the hook as we can construct lua table to pass into the hook and we can also return multiple return values from the hook, which allows us to support rich hook failure reasons properly. Both of these are hard to do when calling hooks directly using hlua.

Reviewed By: StanislavGlebik

Differential Revision: D8711280

fbshipit-source-id: b91f9e47a1f8eab302775a5bbfd61590a8635282
2018-07-05 03:22:52 -07:00
Tim Fox
5adf5c109b Implement per file hooks
Summary:
This diff implements hooks which act upon individual files. The results of the hooks are cached using Asyncmemo.

The cache is currently keyed on (changeset_id, hook_name, file path) but this will change to file content hash once we move to Bonsai changesets.

Reviewed By: StanislavGlebik

Differential Revision: D8707726

fbshipit-source-id: ceaf94abd09e1dd7f6b2d8f9c87a9a221439a252
2018-07-04 07:07:02 -07:00
Tim Fox
f0bbb31967 Implement running of hooks by bookmark
Summary: This diff implements tracking of hooks by bookmark in the hook manager and functionality to run hooks per bookmark.

Reviewed By: StanislavGlebik

Differential Revision: D8525598

fbshipit-source-id: 7987d1f8d90a77667f120f4940f12aa3cb5aa86e
2018-07-04 07:07:02 -07:00
Lukas Piatkowski
ce4069cc70 blobimport: load bookmarks before and after importing changesets
Summary:
In case the bookmarks have been updated while we are reading the revlogs we shoud read the bookmarks before reading changestes.
In this diff we are also reading bookmarks after importing so that we ensure that the newest possible version of bookmarks are persisted.

Reviewed By: farnz

Differential Revision: D8723522

fbshipit-source-id: 278382dae10a0554abc8edc398e7a15a37569676
2018-07-03 03:38:10 -07:00
Jeremy Fitzhardinge
a5937a5424 mononoke/dbbookmarks: return txn success as bool
Summary:
We need to be able to distinguish logical transaction failure from
infrastructure failure, so change the `Transaction::commit` future to
`Future<Item=bool, Error=Error>`, where `false` indicates a logical transaction
failure. This allows the caller to determine whether a retry or other recovery
logic is needed.

Reviewed By: lukaspiatkowski

Differential Revision: D8555727

fbshipit-source-id: 8ab64f3019f2644e7eaabc8d699d99aa8eb08fbb
2018-06-29 20:37:09 -07:00
Rain ⁣
d9a1bb87b6 blobimport: use get_usize from cmdlib
Summary: Avoid code duplication

Reviewed By: StanislavGlebik

Differential Revision: D8689430

fbshipit-source-id: 3c140e5e33f02470b79431e7b430a6b78d50ffaf
2018-06-29 14:22:29 -07:00
Rain ⁣
bb861353c5 cmds: move some common code into a shared crate
Summary:
I want to use this code for the bonsai verification tool without
copying it around. It's also a nice simplification of the code.

Reviewed By: jsgf

Differential Revision: D8675825

fbshipit-source-id: cf9432069f154dafeb81a5e93a2fb5cbd717b981
2018-06-28 14:51:56 -07:00
Rain ⁣
09fdc8a71b cmds/runhook: fix spelling
Reviewed By: jsgf

Differential Revision: D8675326

fbshipit-source-id: ca885f2e55af15cd66316554139f7aef0279a6e0
2018-06-28 11:46:07 -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
Rain ⁣
355e1a3216 admin: allow decoding Thrift-serialized structures
Summary: This will be pretty useful while debugging.

Reviewed By: jsgf

Differential Revision: D8667770

fbshipit-source-id: 1c776741844d74529415124ab826b013414678c7
2018-06-28 11:46:06 -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
Lukas Piatkowski
5a5688c2e7 blobrepo: add scuba logging for changeset creation
Summary: more logging more fun

Reviewed By: StanislavGlebik

Differential Revision: D8577655

fbshipit-source-id: 92a160ea8f8c0b8e012a1461fbd3f5d71b4bd171
2018-06-21 15:51:59 -07:00
Rain ⁣
93c181c35d mercurial-types: simplify Manifest API significantly
Summary:
Manifests are always able to return entries immediately, and never
fail.

Reviewed By: lukaspiatkowski, farnz

Differential Revision: D8556499

fbshipit-source-id: e21a2522f1219e47db9b55b24b6ac6c0c463933e
2018-06-20 18:22:55 -07:00
Rain ⁣
972822e218 blobrepo: simplify code for converting bonsai FileChange to hg
Summary:
Fetching the blob is still required to compute the node hash, but we don't have
to reupload it.

Reviewed By: farnz

Differential Revision: D8508462

fbshipit-source-id: 341a1a2f82d8f8b939ebf3990b3467ed7ad9244c
2018-06-20 13:24:57 -07:00
Rain ⁣
4eca2ec2d9 upload file blobs as Thrift data structures
Summary:
This will also allow file blob sharing between the Mercurial and Mononoke
data models.

Reviewed By: farnz

Differential Revision: D8440330

fbshipit-source-id: a29cd07dcecf0959dffb74b7428f3cb11fbd3db6
2018-06-20 13:24:56 -07:00
Rain ⁣
8b05fd5c16 blobrepo: use thrift blobs for manifests
Summary:
Store manifests as Thrift blobs instead. Required fixing up a lot of
different places, but they should all be pretty clear now.

Reviewed By: farnz

Differential Revision: D8416238

fbshipit-source-id: 523e3054e467e54d180df5ba78445c9b1ccc3b5c
2018-06-20 13:24:56 -07:00
Rain ⁣
9ede6636a7 BREAKING CHANGE: switch to Thrift encoding for changesets
Summary:
Pretty straightforward. Also using this opportunity to add per-repo
prefixes, since all the hashes are going to break anyway.

Note for reviewers: almost all the change is regenerated test fixtures (unfortunately necessary to make atomic). The actual substantive changes are all in the first few files.

Reviewed By: farnz

Differential Revision: D8392234

fbshipit-source-id: c93fc8c6388cb00fe5cff95646ad8c853581cb8c
2018-06-20 13:24:56 -07:00
Tim Fox
7a71a18012 Introduce ChangesetStore so hook manager can get changesets from blobstore or in memory cache
Summary:
This diff introduces the ChangesetStore trait so the HookManager does not directly depend on the BlobRepo. This means the manager can obtain changesets from a simple in memory implementation of ChangesetStore which can be populated with changesets before they are committed to the server. This means the exact same hook manager logic can be used irrespective of whether the changesets are committed or not.

The diff includes two implementations of ChangesetStore - A simple in memory implementation backed by a HashMap, and one that backs onto BlobStore.

Reviewed By: StanislavGlebik

Differential Revision: D8446430

fbshipit-source-id: 8d14e48cb562fcd10a17370e34f13a662af827df
2018-06-19 20:53:00 -07:00
Tim Fox
d7348170c0 Implement memoization of hooks with Asyncmemo
Summary: This diff implements memoization of hooks. If a hook has already been run against the same changeset it is not run again, instead the cached result is used.

Reviewed By: StanislavGlebik

Differential Revision: D8431102

fbshipit-source-id: b4080ba48a3214e767392cbcb46425aa05bc2b64
2018-06-18 13:52:21 -07:00
Tim Fox
06b60d5f67 Refactor hook manager to take changeset_id and lookup changeset internally
Summary: This diff refactors the hook manager to run hooks based on a changeset_id not the actual changeset. The actual changeset is looked up by the hook manager lazily when running a hook. This is needed to make it work well for AsyncMemo as we don't want the changeset cached in the key.

Reviewed By: StanislavGlebik

Differential Revision: D8422442

fbshipit-source-id: 40bc89124942e05c5aaeb2b4ee00215afd816642
2018-06-18 13:52:21 -07:00
Tim Fox
e5805bb07c Use in memory repo test fixture for runhook tests
Summary: This diff refactors the runhook tests to use the linear fake blobrepo to supply changesets

Reviewed By: farnz

Differential Revision: D8418096

fbshipit-source-id: 74fd2578095dbae86ed9e96eac3ca4b344c036da
2018-06-18 08:21:25 -07:00