Commit Graph

127 Commits

Author SHA1 Message Date
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
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
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
Stanislau Hlebik
b3dbdab823 mononoke move repo_read_write into a separate crate
Summary:
Will be used to coordinate hg sync job and blobimport - only one should run at
the same time.

Reviewed By: HarveyHunt

Differential Revision: D14799003

fbshipit-source-id: abbf06350114f1d756e288d467236e3a5b7b2f01
2019-05-21 12:25:04 -07:00
Pavel Aslanov
8f136b8f8f fix rust-2018 compatibility when imported with use statement
Summary: fix rust-2018 compatibility when imported with use statement

Reviewed By: StanislavGlebik

Differential Revision: D14747514

fbshipit-source-id: 8e160c23c3aa079e716d42c1dc92fc49a35b00a3
2019-05-21 12:25:02 -07:00
Pavel Aslanov
fe1a792e2b fix rust-2018 compatibility when imported with use statement
Summary: fix rust-2018 compatibility when imported with use statement

Reviewed By: StanislavGlebik

Differential Revision: D14746613

fbshipit-source-id: 561cdbb969097a45553c8741ee9c55a9d96144b6
2019-05-21 12:25:01 -07:00
Pavel Aslanov
1ba56177c4 implementation of listkeyspatterns wire protocol command
Summary: add support for `listkeyspattern` write protocol command

Reviewed By: StanislavGlebik

Differential Revision: D14727722

fbshipit-source-id: d0883d26109c70f8f5fcd1f0241baab0f5002f81
2019-05-21 12:25:01 -07:00
Stanislau Hlebik
34e77e6d94 mononoke: append metadata in getpackv1
Summary:
getpackv1 needs to return copy metadata together with the content. This diff
fixes it

Reviewed By: kulshrax

Differential Revision: D14668319

fbshipit-source-id: 56a6ea2eb3a116433446773fa4fbe1f5a66c5746
2019-05-21 12:24:53 -07:00
Laurence Emms
491abcd4a8 Removed HgNodeHash from known()/lookup()/heads()/between() methods in
Summary:
Removed references to HgNodeHash in repo_client in the specified functions. In
addition, updated other files due to type related dependencies.

Reviewed By: StanislavGlebik

Differential Revision: D14543934

fbshipit-source-id: b0d860fe7085ed4b91a62ab1e27fb2907a642a1d
2019-05-21 12:24:52 -07:00
Jeremy Fitzhardinge
d76d128059 mononoke: move memblob and prefixblob out of the base blobstore crate
Summary: Slim down the blobstore trait crate as much as possible.

Reviewed By: aslpavel

Differential Revision: D14542675

fbshipit-source-id: faf09255f7fe2236a491742cd836226474f5967c
2019-03-25 12:34:36 -07:00
Stanislau Hlebik
a98f532abd mononoke: fix of the discovery problem
Summary:
This is the test to cover tricky case in the discovery logic.
Previously Mononoke's known() wireproto method returned `true` for both public
and draft commits. The problem was in that it affects pushrebase.

There are a few problems with the current setup. A push command like `hg push
-r HASH --to BOOK` may actually do two things - it can either move a bookmark
on the server or do a pushrebase. What it does depends on how discovery phase
of the push finishes.

Each `hg push` starts with a discovery algorithm that tries to figure out what commits
to send to the server. If client decides that server already has all the
commits then it'll just move the bookmark, otherwise it'll run the pushrebase.

During discovery client sends wireproto `known()` method to the server
with a list of commit hashes, and server returns a list of booleans telling if
a server knows the commit or not. Before this diff Mononoke returned true for
both draft commits and public commits, while Mercurial returned true it only
for public commits.

So if Mononoke already has a draft commit (it might have it because the commit was created
via `hg pushbackup` or was created in the previous unsuccessful push attempt),
then hg client discovery will decide to move a bookmark instead of
pushrebasing, which in the case of master bookmark might have disastrous
consequences.

To fix it let's  return false for draft commits, and also implement `knownnodes` which return true for draft commits (a better name for these methods would be `knownpublic` and `known`).

Note though that in order to trigger the problem the position of the bookmark on the server
should be different from the position of the bookmark on the client. This is
because of short-circuting in the hg client discovery logic (see
https://fburl.com/s5r76yle).

The potential downside of the change is that we'll fetch bookmarks more often,
but we'll add bookmark cache later if necessary.

Reviewed By: ikostia

Differential Revision: D14560355

fbshipit-source-id: b943714199576e14a32e87f325ae8059d95cb8ed
2019-03-25 02:20:53 -07:00
Stanislau Hlebik
98497d1d95 mononoke: fetch all params in getpackv1 before responding
Summary: That prevents possible deadlocks

Differential Revision: D14565245

fbshipit-source-id: 15faffac38700cd4b9fc0b487721cff0844e40b1
2019-03-21 14:01:07 -07:00
Harvey Hunt
e915e3a168 mononoke: Add lock reason to RepoReadOnly type
Summary:
As part of the mononoke lock testing, we realised that it would
be helpful to see why a repo is locked. Add the ability to express this
to the RepoReadOnly enum entry.

Reviewed By: aslpavel

Differential Revision: D14544801

fbshipit-source-id: ecae1460f8e6f0a8a31f4e6de3bd99c87fba8944
2019-03-20 13:45:44 -07:00
Stanislau Hlebik
d0e1e75c75 mononoke: count num files correctly in getpackv1
Summary:
Previously it was counting all stream entries, and for each file we have more
than one entry. This diff fixes it

Reviewed By: aslpavel

Differential Revision: D14519710

fbshipit-source-id: faf31f92933d63c3d4015efdc71eabb6c21888d7
2019-03-19 06:02:26 -07:00
David Budischek
d5063dbf14 Improve clone logging
Summary: To verify that slow downloads are caused by the client connection we log the total amount of time spent downloading files from Manifold.

Reviewed By: HarveyHunt

Differential Revision: D14502779

fbshipit-source-id: 9d6e1fa18faa4689680ed39087aefd418ac2bf62
2019-03-19 05:49:31 -07:00
Stanislau Hlebik
f9e17c1f79 mononoke: add timeout on the whole stream
Summary: Same as with getfiles

Reviewed By: aslpavel

Differential Revision: D14519595

fbshipit-source-id: 972263f66ec7c4881926cd67aaf39bc206b8f1c8
2019-03-19 05:44:35 -07:00
Stanislau Hlebik
c16311a302 mononoke: validate content in getpackv1
Summary: Let's validate the content we return to users in the same way we do it for getfiles

Reviewed By: farnz

Differential Revision: D14420148

fbshipit-source-id: e109f6586210858e26334c1547d374c1c9b9e441
2019-03-18 11:35:11 -07:00
Harvey Hunt
3d724de339 mononoke: Allow dynamic repo read_only mode
Summary:
Allow using a database entry to determine if a repository
is in read-only mode.

If a repo is marked read/write in the config then we will communicate with the db.

Reviewed By: ikostia

Differential Revision: D14279170

fbshipit-source-id: 57abd597f939e57f274079011d2fdcc7e7037854
2019-03-18 08:53:53 -07:00
David Budischek
2a93fe345c Block non fastforward bookmark moves
Summary:
This is a hook in mercurial, in Mononoke it will be part of the implementation. By default all non fastforward pushes are blocked, except when using the NON_FAST_FORWARD pushvar (--non-forward-move is also needed to circumvent client side restrictions). Additionally certain bookmarks (e.g. master) shouldn't be able to be moved in a non fastforward manner at all. This can be done by setting block_non_fast_forward field in config.

Pushrebase can only move the bookmark that is actually being pushrebased so we do not need to check whether it is a fastforward move (it always is)

Reviewed By: StanislavGlebik

Differential Revision: D14405696

fbshipit-source-id: 782b49c26a753918418e02c06dcfab76e3394dc1
2019-03-18 04:12:09 -07:00
Stanislau Hlebik
27c75bd136 mononoke: refactor validate_content() function
Summary:
Before adding hash validation to getpackv1 let's do this refactoring to make it
easier.

This diff also make hash validation more reliable. Previously we were
refetching the same file content again during validation instead of verifying the actual content
that was sent to the client. Since the content was in cache it was fine, but
it's better to check the same content that's sent to the client.

This diff also adds a integration test

Reviewed By: jsgf

Differential Revision: D14407292

fbshipit-source-id: b0667cb3dd6a7e0cee0b02cf87a61d43926d6058
2019-03-15 11:52:38 -07:00
Stanislau Hlebik
80a377dbac mononoke: add logging to getpackv1
Summary: Let's log it to scuba and to scribe just as we do with getfiles requests.

Reviewed By: jsgf

Differential Revision: D14404236

fbshipit-source-id: 079140372c128ee30e152c5626ef8f1127da36b1
2019-03-15 11:52:38 -07:00
Stanislau Hlebik
2e7a787a11 mononoke: handle getpackv1 request on Mononkoe
Summary:
The diff adds support for getpackv1 request. Supporting this request is
necessary because hg client will stop using getfiles soon.

There are two main differences between getfiles and getpackv1. getfiles returns
loose files formats, while getpackv1 returns wirepack pack file (same format as
used by gettreepack). getpackv1 supports fetching more than one filenode per
file.

Differential Revision: D14404234

fbshipit-source-id: cfaef6a2ebb76da2df68c05e838d89690f56a9f0
2019-03-15 11:52:38 -07:00
Johan Schuijt-Li
758716b6a6 mononoke: increase getfiles timeout to 90 minutes
Summary: Increase timeout in line with observed operations.

Differential Revision: D14421000

fbshipit-source-id: 68941a5188e41c6dd7fbb3b59af0a912327f76a4
2019-03-12 07:14:00 -07:00
Johan Schuijt-Li
5f4a2e3827 clienttelemetry: introduce support
Summary:
Client telemetry is used to send which commands are being run on the client,
which makes debugging slow sessions easier. For the client perspective, the
server hostname is send back so that the user knows to which physical host it's
connected, which is also useful debug info.

Reviewed By: StanislavGlebik

Differential Revision: D14261097

fbshipit-source-id: f4dc752671b76483f9dcb38aa4e3d16680087850
2019-02-28 10:34:47 -08:00
Arun Kulshreshtha
f34d6babe3 Make history fetching depth configurable
Summary: Optionally specify a max depth for history fetching.

Reviewed By: StanislavGlebik

Differential Revision: D14218337

fbshipit-source-id: b6b92181172637e58a43bf61793257559915c7f1
2019-02-27 12:43:57 -08:00
Arun Kulshreshtha
b9ecc7835a Use maplit
Summary: Use `maplit` crate for initializing HashSets.

Reviewed By: quark-zju

Differential Revision: D14216491

fbshipit-source-id: 40df54d3c87a710b922d2aef8df3e9022e4ad0e9
2019-02-25 16:15:50 -08:00
Johan Schuijt-Li
616654450b unify lz4 compression with hg
Summary:
Mononoke and hg both have their own implementation wrappers for lz4
compression, unify these to avoid duplication.

Reviewed By: StanislavGlebik

Differential Revision: D14131430

fbshipit-source-id: 3301b755442f9bea00c650c22ea696912a4a24fd
2019-02-21 06:27:53 -08:00
Johan Schuijt-Li
50b7d93014 rustfmt before editing
Summary: Code format.

Reviewed By: StanislavGlebik

Differential Revision: D14131431

fbshipit-source-id: 1b6f89382bbbe8b5bb033e3ecf7620d161d587e8
2019-02-21 06:27:53 -08:00
Stanislau Hlebik
ee3babeb80 mononoke: parse getbundle caps and check phases
Summary:
Followup from the previous diff. Instead of parsing it in nom let's write a
small function that does all the parsing of getbundle capabilities.

Reviewed By: lukaspiatkowski

Differential Revision: D13972034

fbshipit-source-id: a6fbc9742217f3d77e7d93bb8cf5165f94d8b3e1
2019-02-15 05:12:29 -08:00
Stanislau Hlebik
1ec2d25722 mononoke: revert D13751782
Summary:
It breaks mononoke traffic replay - https://fburl.com/scuba/1rxovt8t.
It changed how mononoke logs requets to replay and now bundlecaps is a dict
instead of a string, so this line in traffic replay fails -
https://fburl.com/g8gwhzrq.

Reviewed By: lukaspiatkowski

Differential Revision: D13972033

fbshipit-source-id: a6e8258da8e7a5b6f90b869781f448a2202a07a1
2019-02-15 05:12:29 -08:00
Arun Kulshreshtha
4257aa7c1b Move HgFileHistoryEntry to mercurial-types
Summary: Move the `HgFileHistoryEntry` type from the `remotefilelog` crate into `mercurial-types`, since it is useful outside of `repo_client`, and will be extended with additional functionality unrelated to its existing usage later in this stack.

Reviewed By: StanislavGlebik

Differential Revision: D14079336

fbshipit-source-id: d65d6dded840e396e227c9af2aa6dc27097dcbef
2019-02-14 13:15:54 -08:00
Arun Kulshreshtha
27a70a9ea2 Add method to get file history
Summary: Add a method for fetching the history of a given file (specified as a path/filenode pair). This will be used by the API server to answer file history requests.

Reviewed By: lukaspiatkowski

Differential Revision: D13910533

fbshipit-source-id: 985dc8c19f844a0d521d672848b7309dbaa07e85
2019-02-13 16:49:16 -08:00
Kostia Balytskyi
02ab033b04 mononoke: enable bundle2 content preservation conditionally
Summary: This is adds a metaconfig option to preserve push/pushrebase bundles in the blobstore.

Reviewed By: StanislavGlebik

Differential Revision: D14020299

fbshipit-source-id: 94304d69e0ac5d81232f058c6d94eec61eb0020a
2019-02-12 13:03:48 -08:00
Kostia Balytskyi
19f4c1cd8d mononoke: add a no-op code to preserve raw bundle2 contents in the blobstore
Summary:
This diff does not change anything on it's own, but rather adds the not
reachable (but already somewhat tested) code to preserve bundles when doing
pushes and pushrebases.

I want to land it now so that conflict resolution is easier.

Reviewed By: StanislavGlebik

Differential Revision: D14001738

fbshipit-source-id: e3279bc34946400210d8d013910e28f8d519a5f8
2019-02-11 14:48:37 -08:00
Stanislau Hlebik
0090411050 mononoke: increase getfiles timeout
Reviewed By: aslpavel

Differential Revision: D14024469

fbshipit-source-id: 8c7fa1543083aeddbae26ed5c7167de6e74a0c54
2019-02-11 08:07:14 -08:00
Stanislau Hlebik
56a2ad455c mononoke: remove mysql schemas
Summary:
These are **not** the schemas that we use in production.
So at the moment they are not used for anything and they just create confusion.

Reviewed By: aslpavel

Differential Revision: D13986001

fbshipit-source-id: 7aae0a5da474f579c9cdf1bbf5dfe183835cae2d
2019-02-08 03:04:01 -08:00
Lukas Piatkowski
c163368a07 blobrepo/src/file.rs: use HgFileNodeId instead of HgNodeHash and propagate it
Summary: HgFileNodeId is a stronger typed id, so it is prefered to use it instead of HgNodeHash whenever it is identifying a filenode

Reviewed By: aslpavel

Differential Revision: D13986172

fbshipit-source-id: c0334652345acb868e86c38b8c0045e9c023c176
2019-02-07 04:04:28 -08:00
Lukas Piatkowski
515a2909eb monononoke hashes: remove usages of borrows of hashes which are Copy
Summary: The Copy trait means that something is so cheap to copy that you don't even need to explicitly do `.clone()` on it. As it doesn't make much sense to pass &i64 it also doesn't make much sense to pass &<Something that is Copy>, so I have removed all the occurences of passing one of ouf hashes that are Copy.

Reviewed By: fanzeyi

Differential Revision: D13974622

fbshipit-source-id: 89efc1c1e29269cc2e77dcb124964265c344f519
2019-02-06 15:11:35 -08:00
Arun Kulshreshtha
5e8802209e split up create_remotefilelog_blob
Summary: The `create_remotefilelog_blob` function was fairly large, but consisted of several distinct steps in a long `Future` combinator chain. This diff refactors this module, splitting up this function into several smaller ones, and adding types for intermediate results where needed.

Reviewed By: StanislavGlebik

Differential Revision: D13953990

fbshipit-source-id: 61d8115cc80d44bc624fa6de8a4ffcf2cdd5266e
2019-02-05 21:23:24 -08:00
Stanislau Hlebik
614a246af4 mononoke: extract remotefilelog and streaming clone
Summary: To decrease compile time

Reviewed By: jsgf

Differential Revision: D13901611

fbshipit-source-id: 8d74589227117cd4526299dfbb80d292167107b3
2019-02-05 01:23:15 -08:00
Arthur Kushka
3f1b256609 Improved internal representation of GetbundleArgs.bundlecaps
Summary:
Implemented advanced parser to parse bundlecaps json object into more suitable to work datastructure.

Patched version of D13602738

Reviewed By: ikostia

Differential Revision: D13751782

fbshipit-source-id: 977b70c121d0df587082b8db615cbea7a00e3aa4
2019-01-31 02:08:12 -08:00
Stanislau Hlebik
4d48415149 mononoke: split metaconfig crate
Summary:
Currently if a crate depends even on a single type from metaconfig then in
order to compile this trait buck first compiles metaconfig crate with all the
logic of parsing the configs.

This diff split metaconfig into two crates. The first one just holds the types for
"external consumption" by other crates. The second holds the parsing logic.

That makes builds faster

Reviewed By: jsgf, lukaspiatkowski

Differential Revision: D13877592

fbshipit-source-id: f353fb2d1737845bf1fa0de515ff8ef131020063
2019-01-31 00:41:48 -08:00
Stanislau Hlebik
a055f8e409 mononoke: move open_blobrepo to blobrepo crate and remove TestDelay blobrepo type
Summary:
The main reason to do it is to remove dependency from cmdlib to repo_client.
repo_client depends on a lot of other crates like bundle2-resolver, hooks etc.
And it means that in order to compile mononoke_admin we need to compile these
crates too. By moving open_blobrepo into blobrepo crate we are removing
unnecessary dependencies.

Also let's remove unused blobrepo type

Reviewed By: aslpavel

Differential Revision: D13848878

fbshipit-source-id: cd3d04354649cdb5b2947f08762051318725c781
2019-01-30 06:31:10 -08:00
Stanislau Hlebik
57931e59ac mononoke: remove Arc<BlobRepo> + rustfmt
Reviewed By: lukaspiatkowski

Differential Revision: D13818633

fbshipit-source-id: 98a18877ca82afb4ac38981ca2ee59cff12b99d0
2019-01-28 14:40:40 -08:00
Stanislau Hlebik
67f220c89c mononoke: fix pushrebasing an empty commit
Summary:
Previously pushrebasing an empty commit failed because we assumed that root
manifest of a commit is always sent in a bundle. This diff removes this
assumption

Reviewed By: lukaspiatkowski

Differential Revision: D13818556

fbshipit-source-id: 44e96374ae343074f48e42a90c691b21e3c41386
2019-01-28 14:40:40 -08:00
Liubov Dmitrieva
610671e486 implement bypass readonly option (to be used for Commit Cloud in
Summary:
Next step is to change infinitepush / cloud sync to pass this pushvar to
Mononoke

Reviewed By: StanislavGlebik

Differential Revision: D13802402

fbshipit-source-id: 25e3d699bd934e3e015b9784040bd2dc4b43188d
2019-01-24 08:50:27 -08:00
Liubov Dmitrieva
abe70d4324 move Send + Sync to the trait for LeastCommonAncestorsHint
Summary: This hint is passed to many places, so it reduces the code.

Reviewed By: StanislavGlebik

Differential Revision: D13802159

fbshipit-source-id: 891eef00c236b2241571e24c50dc82b9862872cc
2019-01-24 07:59:46 -08:00
Arthur Kushka
aa4a1deb0a Back out "Improved internal representation of GetbundleArgs.bundlecaps"
Summary: mononoke: Original commit changeset: 6cb5124c7893

Reviewed By: StanislavGlebik

Differential Revision: D13751021

fbshipit-source-id: b80da7ebbaaca3324078efda15704c185050b35f
2019-01-21 07:43:26 -08:00
Arthur Kushka
21048bd300 Improved internal representation of GetbundleArgs.bundlecaps
Summary: Implemented advanced parser to parse bundlecaps json object into more suitable to work datastructure.

Reviewed By: aslpavel

Differential Revision: D13602738

fbshipit-source-id: 9a2f8e78d55a21e80229aae23e5a38f6cc14c7e8
2019-01-21 02:39:04 -08:00
Stanislau Hlebik
b909f2bc9c mononoke: per wireproto command timeout
Summary:
Previously we had a timeout per session i.e. multiple wireproto command will
share the same timeout. It had a few disadvantages:

1) The main disadvantage was that if connection had timed out we didn't log
stats such as number of files, response size etc and we didn't log parameters
to scribe. The latter is even a bigger problem, because we usually want to
replay requests that were slow and timed out and not the requests that finished
quickly.

2) The less important disadvantage is that we have clients that do small
request from the server and then keep the connection open for a long time.
Eventually we kill the connection and log it as an error. With this change
the connection will be open until client closes it. That might potentially be
a problem, and if that's the case then we can reintroduce perconnection
timeout.

Initially I was planning to use tokio::util::timer to implement all the
timeouts, but it has different behaviour for stream - it only allows to set
per-item timeout, while we want timeout for the whole stream.
(https://docs.rs/tokio/0.1/tokio/timer/struct.Timeout.html#futures-and-streams)
To overcome it I implemented simple combinator StreamWithTimeout which does
exactly what I want.

Reviewed By: HarveyHunt

Differential Revision: D13731966

fbshipit-source-id: 211240267c7568cedd18af08155d94bf9246ecc3
2019-01-18 08:35:52 -08:00