Commit Graph

1427 Commits

Author SHA1 Message Date
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
Lukas Piatkowski
6de0ccc24e filenodes: add sqlfilenodes implementation using common/rust/sql instead of diesel
Reviewed By: farnz

Differential Revision: D10261151

fbshipit-source-id: fdae33f370123cd968e9ee6ef0e20c55d9f6e88b
2018-10-11 10:52:05 -07:00
Lukas Piatkowski
dd79d028dd filenodes: fix dieselfilenodes-cmd by calling it's code inside tokio
Reviewed By: farnz

Differential Revision: D10251659

fbshipit-source-id: 6f288a41d63d25521efd41349c4bd34b77a2a40b
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
Stanislau Hlebik
3c077a3875 mononoke: fix hook tailer
Summary: It got a bit rusty, this diff adds missing stuff

Reviewed By: farnz

Differential Revision: D10302729

fbshipit-source-id: af598f8c8fdd5c938c07052c03ab0f84fc6d3c20
2018-10-11 05:50:48 -07:00
Stanislau Hlebik
b298a691ca mononoke: fix changed file calculation
Summary:
One brainless idiot decided to prune all trees from changed files calcualation.
Since it also prunes subtrees, that leaves with just files in the root
directory.

Reviewed By: lukaspiatkowski

Differential Revision: D10302299

fbshipit-source-id: 8fe2c4ad8de998dfd4083d97cd816d85b5fec604
2018-10-11 05:50:48 -07:00
Stanislau Hlebik
382c1e8d31 mononoke: conflict_markers hook
Summary:
Hooks that makes sure that there are no conflict markers in file contents.
This hook is bypassable.

Reviewed By: purplefox

Differential Revision: D10260230

fbshipit-source-id: b9d69e757f18ed3f4f889a01032ef7360cba6867
2018-10-11 05:50:48 -07:00
Stanislau Hlebik
d5a8790a56 mononoke: slightly better printing of hook failures
Summary: Not a final version for sure, just a small improvement

Reviewed By: lukaspiatkowski

Differential Revision: D10260231

fbshipit-source-id: 9f9f61f23da5ac9a5d1abc9ad2f50900ca434326
2018-10-11 05:50:48 -07:00
Stanislau Hlebik
a79d9d4a25 mononoke: add pushvars bypasses
Summary: Pushvars is a one more way to bypass hooks. This diff implements it

Reviewed By: purplefox

Differential Revision: D10257602

fbshipit-source-id: 1bd188239878ff917ded7db995ea2453da9f64c4
2018-10-11 05:50:48 -07:00
Stanislau Hlebik
ceba87afec mononoke: add commit message bypasses
Summary:
Let's add a logic to allow users to bypass hooks.

We'll have two ways to bypass hooks. One is via a string in commit message,
another is via pushvars.
This diff implements the first one.

Reviewed By: purplefox

Differential Revision: D10255378

fbshipit-source-id: 31e803a58e2f4798294f7c807933c8e26de3cfaf
2018-10-11 05:50:47 -07:00
Lukas Piatkowski
177bbc024e cmdlib: be able to parse --myrouter-port argument and ignore it
Summary: also includes a fix for blobimportjob passing an empty argument to blobimport when was not used

Reviewed By: farnz

Differential Revision: D10298965

fbshipit-source-id: 1e9475c53a7e0b7ea211cc8fbd2c327327b66c65
2018-10-10 08:21:18 -07:00
Tim Fox
370c9f9bd9 Add hook method to get any file content
Summary: Add a new method for changeset hooks to allow the content of any file to be retrieved.

Reviewed By: StanislavGlebik

Differential Revision: D10255914

fbshipit-source-id: 4ec89369835a2807675b1eda41b4399cf0c66b32
2018-10-10 03:35:24 -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
Stanislau Hlebik
f9cdae09c6 mononoke: replace PerFile hook with PerAddedOrModified
Summary:
That's a bit controversial, however I think it's worth it. Many file hooks
should be run only on files that exist in the repo (for example,
https://fburl.com/1cj8wm3p, https://fburl.com/t06fjwak). If you want to do
anything on deleted files then just write a changeset hook.

Reviewed By: jsgf

Differential Revision: D10239186

fbshipit-source-id: 3cb563b81ec51298623cecaf976b5a8fe50dc71c
2018-10-09 02:05:55 -07:00
Lukas Piatkowski
0f24377899 rust-crates-io: add crossbeam to tp2
Reviewed By: ikostia

Differential Revision: D10244968

fbshipit-source-id: 8d06bb64b6a1227ae589caf0588a1f3657603ce9
2018-10-08 21:36:00 -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
Stanislau Hlebik
9685ca7c45 mononoke: actually pass comments
Summary: Fix copy-paste error

Reviewed By: farnz

Differential Revision: D10237928

fbshipit-source-id: 18ecfeefe5506ac51d621d8be0796565d11d3794
2018-10-08 09:06:26 -07:00
Stanislau Hlebik
c3b5ee6854 mononoke: add (re) for lines ending with whitespace in integration tests
Summary:
Many editors remove trailing whitespaces on save. That makes modifying these
files annoying. Adding ` (re)` mitigates the issue

Reviewed By: farnz

Differential Revision: D10237590

fbshipit-source-id: 1473f35023b878f21ff22bd5a5ccb5f11884cef3
2018-10-08 09:06:26 -07:00
Stanislau Hlebik
d95fa203ce mononoke: pass change file type information to hooks
Summary:
Hooks need to know whether file was added, modified or removed. For example, we
can't fetch content of a removed file. Also hook authors may want to allow
modifying existing files of a particular type, but they may want to disallow
addition of new files of this type.

`cs.files()` doesn't give information about whether a file was
added/deleted/modified, so we have to use `get_changed_stream` function from
manifest_utils.

Note - currently it still returns incorrect list of changed files for merges.
It will be fixed in the next diffs.

Reviewed By: farnz

Differential Revision: D10237587

fbshipit-source-id: cd7f76334070cde451b4690071d03275e40c95f3
2018-10-08 09:06:26 -07:00
Stanislau Hlebik
a1b12f6beb mononoke: remove broken assert
Summary:
This assert was just broken - it's fine to call `get_full_path()` on file
entry. What's disturbing is that there were no tests that cover this behaviour
i.e. no tests returned modified file!

This diff fixes both problems

Reviewed By: farnz

Differential Revision: D10237589

fbshipit-source-id: dcb7f1977768262491b4624a30a5e861c3c1eadf
2018-10-08 09:06:25 -07:00
Anastasiya Zhyrkevich
c9e390669d tests for changegroup pack/unpack for version 3
Summary:
Tests are for changegroup version3
Unitests in part_inner.rs
QuickCheck for Ch3Packer and Unpacker.

Packer has the same implementation, as Packer packs everything operating with chunks, and does not care about sections.

In quickcheck tests, my proposal is to have similar CgSeqGenerator for both of Cg versions.
But as sections are different, to introduce optional sections.

Reviewed By: StanislavGlebik

Differential Revision: D10192025

fbshipit-source-id: bef0d654724f18177461c6326324d6972943eb23
2018-10-05 02:51:24 -07:00
Anastasiya Zhyrkevich
8dd9b3f937 parser for change group version 3
Summary:
Support ChangeGroup version 3 from Mercurial

on Push, Hg client sends bundle, which is encoded in type 2 or type 3.
The type depends on which extentions are turned on in client.

The type is written in PartHeader, part_type: B2xRebase, aparams: {"cgversion": b"03"}

The differences between type 2 and type 3:
- could be found in fbcode/scm/hg/mercurial/help/internals/changegroups.txt
- The flow of parts is different. There is a new part in type 3:
-- type 2: Changeset, Manifest,                        Filename, Filelog
-- type 3: Changeset, Manifest, Treemanifest, Filename, Filelog
- According to hg implementation, Treemanifest part should always be empty (consists of Section End chunk (4 bytes of zeores) )
- Different chunk header size, as flags (unsigned int) is added. (type 2 - 100 bytes, type3 - 102 bytes in total)

Mononoke should support both versions, as if  LFS is turned on, hg client is sending bundles in version 3 type.

Reviewed By: StanislavGlebik, farnz

Differential Revision: D10162321

fbshipit-source-id: f2ae664206b147db5f24312942d7fcf89ccd69b3
2018-10-05 02:51:23 -07:00
Simon Farnsworth
6e2455a12e Hook up (untested) support for streaming clones
Summary:
We now have a way for a MySQL database to tell us how to send
streaming clones to the client. Hook it all up, so that (with any luck), once
we have data in MySQL and the blobstore, we'll see working streaming clones.

Reviewed By: StanislavGlebik

Differential Revision: D10130774

fbshipit-source-id: b22ffb642d0a54b09545889779f79e7a0f81acd7
2018-10-04 11:37:46 -07:00
Pavel Aslanov
c920dcc0a6 fix copy metadata generation
Summary:
We used generate copy metadata which  mercurial understand but works a bit differently
Relevant mercurial code:
```
def packmeta(meta, text):
    keys = sorted(meta)
    metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys)
    return "\1\n%s\1\n%s" % (metatext, text)
```

Reviewed By: StanislavGlebik

Differential Revision: D10200805

fbshipit-source-id: f17a51a6aac2e1d3671fbbf3e969ed747e2fce18
2018-10-04 10:08:40 -07:00
Tim Fox
2b90a41b8b Add hook method to get file content
Summary: Add a new hook method to return file contents

Reviewed By: lukaspiatkowski

Differential Revision: D10029268

fbshipit-source-id: c7ba41f6273e920ee398e15b6461a4b422f0420b
2018-10-02 07:07:16 -07:00
Tim Fox
debd4a5f95 Integrate hooks into mononoke write path
Summary: Integrate hook manager into the Mononoke pushrebase path

Reviewed By: lukaspiatkowski

Differential Revision: D9896005

fbshipit-source-id: ffd79b539288d95b134af97b776b7fcc3afa0ce7
2018-10-02 07:07:16 -07:00
Pavel Aslanov
e8e5131447 compare hg/mononoke changesets
Summary: This adds `--compare-commits` option for pushrebase replayer. Which also check that commits are close enough to treat them as equal for the purpose of pushrebase.

Reviewed By: StanislavGlebik

Differential Revision: D10084308

fbshipit-source-id: f1fd05173a9a7663125a89dd03b79b2deea40dc4
2018-10-02 03:52:01 -07:00
Jun Wu
5828eb48a2 mononoke-types: clarify that copy_from cs_id must match one of parents
Summary:
Add a comment about the restriction of cs_id used in CopyInfo. It must match
one of parents mentioned in BonsaiChangeset.

This makes it clear the cs_id won't be the commit introducing the file
revision. It cannot be other things like an ancient commit in the history, or
a future commit in a different branch, either.

Reviewed By: sunshowers

Differential Revision: D10137729

fbshipit-source-id: 9b2afd7689bb93d45514ea9ab66667eb46a3a11f
2018-10-01 18:06:42 -07:00
Simon Farnsworth
cd9679166e cleanup warning: causes has become iter_chain in new versions
Summary: This popped up while I was building Mononoke - fix it.

Reviewed By: StanislavGlebik

Differential Revision: D10126386

fbshipit-source-id: 117239dea88c3ecd921f852ce86691ba6aa8bb07
2018-10-01 07:39:00 -07:00
Stanislau Hlebik
836414034d mononoke: speed up integration tests
Summary: cachelib takes a lot of times to init, and it's not used in the tests.

Reviewed By: farnz

Differential Revision: D10123692

fbshipit-source-id: bce82af3f56aa8829127bf4c605a1d472735126a
2018-10-01 03:38:19 -07:00
Stanislau Hlebik
d924fc849d mononoke: print error message in tests if blobimport fails in tests
Summary:
It makes it clear why blobimport failed. Before it required modification to the
tests to run `cat FILENAME`, now it's done automatically

Reviewed By: farnz

Differential Revision: D9850279

fbshipit-source-id: b9a252f50b6dcf4906c24aca70fa37a2cec84e46
2018-10-01 03:38:19 -07:00
Stanislau Hlebik
54b1af68e4 mononoke: fix integration tests
Summary: Because of D9926967

Reviewed By: farnz

Differential Revision: D10108576

fbshipit-source-id: 6fa68db1f955bc8edfd12da0e7924f51ae8a9513
2018-09-28 11:06:56 -07:00
Stanislau Hlebik
cfe900cf7b mononoke: cache warmup improvements
Summary: This diff adds better logging for a warmup, and spawns changesets and manifest warmup on different tasks. Manifest warmup is cpu heavy, so changeset warmup has to just wait, that's why sending them to different tasks should help.

Reviewed By: lukaspiatkowski

Differential Revision: D10032437

fbshipit-source-id: fed61db7fdf1c09a14f5f59d54b5eb268cf21e5a
2018-09-28 09:37:00 -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
314db6711d mononoke: do not fail if same certificate was added twice
Reviewed By: farnz

Differential Revision: D10083857

fbshipit-source-id: 6cd7d4f4e58880991ec3f19c83ea1f78d15153aa
2018-09-27 10:37:00 -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
Simon Farnsworth
bbd00294bb Set up the infrastructure to log changesets after commit
Summary:
We want to be able to do post-commit logging for all changesets. Set
up the data structures I intend to use for now, and arrange to discard all
logging.

A later diff will add logging to a ScribeClient.

Reviewed By: StanislavGlebik

Differential Revision: D9995984

fbshipit-source-id: 796b390f6b83ace576f73a217ac564c4251d7ec5
2018-09-27 04:25:14 -07:00
Stanislau Hlebik
8297747e3b mononoke: make AncestorsNodeStream use ChangesetFetcher
Summary:
Main reason is to make startup faster because ChangesetFetcher can uses bulk
caches in the same way as getbundle does.

Reviewed By: farnz

Differential Revision: D10032435

fbshipit-source-id: 717114339edf31865b498893d75695968447bb43
2018-09-26 04:51:45 -07:00
Stanislau Hlebik
7cec9d7878 mononoke: make AncestorNodeStream use ChangesetId
Summary:
Revsets should use ChangesetId instead of NodeHash. This diff cleans up
ancestors revset

Reviewed By: farnz

Differential Revision: D10032436

fbshipit-source-id: 2c7d170738826154e3b606e9e29a739a34b1840e
2018-09-26 04:51:45 -07:00
Stanislau Hlebik
f43eea052e mononoke: increase getbundle buffer
Summary:
From non-master region fetching many changeset entries can be slow. Bumping the
buffer size helped a lot. It shouldn't have negative impact on memory usage
because changeset objects are fairly small.

Reviewed By: farnz

Differential Revision: D10026544

fbshipit-source-id: fa015660a0f7839e73b5aff7d143e85f274dd1b0
2018-09-25 05:07:50 -07:00
Stanislau Hlebik
f0b0fdad63 mononoke: prefetch caches of changesets from blobstore
Summary:
This diff adds a real implementation for CachingChangesetFetcher. Now it
fetches the data for the cache from the blobstore.

The rest is explained in the comments.

Reviewed By: farnz

Differential Revision: D9908320

fbshipit-source-id: 5427f3ed312cb7753434161423cb27b48744347f
2018-09-25 05:07:50 -07:00
Stanislau Hlebik
30ccc3b75b monononoke: add caching changesets fetcher
Summary:
Initial implementation of ChangesetsFetcher that will use cache smarter.
At the moment it doesn't do anything special, but in the next diffs it will pre
warm cache in case it has a lot of cache misses (that's why it has to have a
reference to the cachelib CachePool).

Reviewed By: farnz

Differential Revision: D9908319

fbshipit-source-id: 6377a947696bae6b060de5a441722c28309b341c
2018-09-25 05:07:50 -07:00
Tim Fox
35c734de1d Support access to file content in changeset hooks
Summary:
This diff enables access to file content via contains_string() and len() (same as in file hooks) form inside changeset hooks.
This is necessary as some changeset hooks need access to file content and length, e.g. to compute total changeset size.

Reviewed By: StanislavGlebik

Differential Revision: D9788596

fbshipit-source-id: da7bafe6f6fa17a1f25b42550d0bb1a5d871579e
2018-09-25 04:13:50 -07:00
Stanislau Hlebik
ec43bcc0fb mononoke: add ChangesetFetcher trait
Summary:
High-level goal: we want to make certain big getbundle requests faster. To do
that we'd store blobs of commits that are close to each other in the blobstore
and fetch them only if we had too many cache misses. All this logic will be
hidden in ChangesetFetcher trait implementation. ChangesetFetcher will be
created per request (hence the factory).

Reviewed By: farnz

Differential Revision: D9869659

fbshipit-source-id: 9e3ace3188b3c13f83ef1bd61b668d4f22103f74
2018-09-25 03:23:52 -07:00
Anastasiya Zhyrkevich
617d750703 LFS Api test
Summary:
Integration test for check connection hg client < - > API batch
Checks objects/batch/
Checks lfs/upload/{SHA}

Reviewed By: StanislavGlebik

Differential Revision: D9975015

fbshipit-source-id: 464ca4a2f9f53c1d0a6aa39ada519e598b5974ef
2018-09-24 11:07:13 -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
Jeremy Fitzhardinge
d865e4dfad tp2/rust: update to Rust 1.29
Reviewed By: StanislavGlebik

Differential Revision: D9978034

fbshipit-source-id: 439ef4f558202980585ba8a4660986b31ade3061
2018-09-21 11:37:10 -07:00
Shu-Ting Tseng
96a4cec203 replace testing database with xdb.mononoke_production
Summary:
This is mainly generated by

```
fbgs mononoke_test_2 -l -s | xargs sed -i 's/mononoke_test_2/mononoke_production/g'
```

mononoke config repo is still pending todo. But it's ok to do it in several run
as right now 2 names are pointing to the same shard.

Reviewed By: StanislavGlebik

Differential Revision: D9939694

fbshipit-source-id: ded772037844a220b18d99b207c976b88dafdaa5
2018-09-21 06:26:29 -07:00