Commit Graph

1489 Commits

Author SHA1 Message Date
Meyer Jacobs
cecbca5bb7 edenapi: make tree query method extensible
Summary:
Adds a `WireTreeQuery` enum for query method, with a single `ByKeys(WireTreeKeyQuery)` available currently, to request a specific set of keys.

Leave the API struct alone for now.

Reviewed By: kulshrax

Differential Revision: D23402366

fbshipit-source-id: 19cd8066afd9f14c7e5f718f7583d1e2b9ffac02
2020-09-29 12:08:05 -07:00
Mateusz Kwapich
5bd5fca4e9 add setup runbook to README
Reviewed By: krallin

Differential Revision: D23988329

fbshipit-source-id: a4bfa7826f0c2b0f45f6fe73936138e346bbd7b7
2020-09-29 05:37:30 -07:00
Aida Getoeva
40b8353d21 mononoke: integrate mysql client
Summary:
This diff introduces Mysql client for Rust to Mononoke as a one more backend in the same row with raw xdb connections and myrouter. So now Mononoke can use new Mysql client connections instead of Myrouter.

To run Mononoke with the new backend, pass `--use-mysql-client` options (conflicts with `--myrouter-port`).

I also added a new target for integration tests, which runs mysql tests using mysql client.
Now to run mysql tests using raw xdb connections, you can use `mononoke/tests/integration:integration-mysql-raw-xdb` and using mysql client `mononoke/tests/integration:integration-mysql`

Reviewed By: ahornby

Differential Revision: D23213228

fbshipit-source-id: c124ccb15747edb17ed94cdad2c6f7703d3bf1a2
2020-09-29 03:09:05 -07:00
Mark Thomas
9720cccbe5 test-hooks: use hyphens for bypass string
Summary: We use hyphens in other bypass strings.  Make this consistent in `test-hooks.t` to avoid confusion.

Reviewed By: mitrandir77

Differential Revision: D23964799

fbshipit-source-id: e300bad091aa6c50f5921507117c1019b9863bd5
2020-09-28 11:19:20 -07:00
Kostia Balytskyi
9981ab8454 mononoke: use parent config version if it's available for a single-parent case
Summary:
Let's start actually fixing what commit sync config version is used to remap a commit i.e. we
should use a commit sync config version that was used to remap a parent instead
of using a current version. See more details in
https://fb.quip.com/VYqAArwP0nr1

This diff fixes one particular case and also leaves a few TODOs that we need to
do later

Reviewed By: krallin

Differential Revision: D23953213

fbshipit-source-id: 021da04b0f431767fec5d1c4408287870cb83de1
2020-09-28 10:20:16 -07:00
Kostia Balytskyi
0f47188bd8 mononoke: change TestLiveCommitSyncConfig logic
Summary:
TestLiveCommitSyncConfig is supposed to be a test replacement of
CfgrLiveCommitSyncConfig, however it was quite a different semantic. In
particular, it wasn't even possible to have two versions of the mapping for the
single repo.

This diff changes that. Now we'll have a method to add commit sync config
version, and mark/remove a version as current

Reviewed By: krallin

Differential Revision: D23951202

fbshipit-source-id: 242b4f088f67dac504544987e484cc290ee4e400
2020-09-28 10:20:16 -07:00
Kostia Balytskyi
6690d13a40 mononoke: remove usage of get_current_mover_DEPRECATED method
Summary: Instead of always fetching the current version name to verify working copy let's instead fetch whatever the version was actually used to create this commit.

Reviewed By: krallin

Differential Revision: D23936503

fbshipit-source-id: 811e427eb62741401b866970b4a0de0c1753edb3
2020-09-28 10:20:16 -07:00
Kostia Balytskyi
4c1e9c8538 mononoke: fix verify_working_copy method
Summary:
Turned out validation didn't report an error if source repo contained an entry
that was supposed to be present in target repo but was actually missing.

This diff fixes it.

Reviewed By: krallin

Differential Revision: D23949909

fbshipit-source-id: 17813b4ad924470c2e8dcd9d3dc0852c79473c61
2020-09-28 10:20:16 -07:00
Kostia Balytskyi
3eb00ff939 mononoke: add version to CommitSyncOutcome:: EquivalentWorkingCopyAncestor
Summary: Since now we store it in the db, let's also expose it in CommitSyncOutcome enum

Reviewed By: krallin

Differential Revision: D23936502

fbshipit-source-id: a0758143ceaa8f5706f1d9cfe3040ac91c7bac49
2020-09-28 10:20:15 -07:00
Aida Getoeva
0ba6f9ff35 mononoke/sql_ext: add mysql connections
Summary: The diff adds API to create a set of connections: read, read master and write.

Reviewed By: ahornby

Differential Revision: D23568561

fbshipit-source-id: b3ee954604557497ed56c6b369256b6f76a1e042
2020-09-28 08:13:35 -07:00
Aida Getoeva
77c2ae3673 mononoke/blobstore_healer: use myadmin replication lag
Summary:
This diff makes blobstore healer to use MyAdmin to get replication lag for a DB shard and removes "laggable" interface for connections.

The old "laggable" API worked this way: we maintained potential connections to each possible region, then tried to query replica status on all of them. If there was no replica hosts in some of the regions, we just wanted to ignore it by handling a specific error type.

This is legacy and makes the logic more complicated. We want for the new code to use Myadmin instead.

Reviewed By: krallin

Differential Revision: D23767442

fbshipit-source-id: 9f85f07bd318ad020d203d2bcd1c8898061f7572
2020-09-28 07:19:31 -07:00
Lukas Piatkowski
c807e08a58 mononoke/integration tests: publicize hook and megarepo tests (#61)
Summary: Pull Request resolved: https://github.com/facebookexperimental/eden/pull/61

Reviewed By: farnz

Differential Revision: D23818467

fbshipit-source-id: 72857a4193ee9f218cda06ec98717ea6ecf97dbe
2020-09-28 04:26:09 -07:00
Thomas Orozco
ee9ecf63bb gotham_ext: ^ is not **
Summary:
I spotted D23955629 recently, and it turns out I made the same mistake in LFS.
Let's fix it. In order to keep the same semantics (yield on every chunk from
the filestore), I lowered the threshold a bit from what it was intended to be.

Reviewed By: johansglock

Differential Revision: D23960152

fbshipit-source-id: 4d384752228fd125ade7e032a477648798e7fa44
2020-09-28 03:41:24 -07:00
Lukas Piatkowski
3615a09d6f remove fbsource version, import github version
Summary:
This is (I think) the last step required to make rust-partial-io be github-first.

The diff was created using:
* `zbgs partial-io` and remove all instances of it in fbsource
* `hg rm common/rust/partial-io`
* add `partial-io` to `third-party/rust/Cargo.toml`
* `common/rust/tools/reindeer/vendor` to vendor
* `buck build eden/mononoke/mercurial/...` to check that it builds correctly
* `buck run //common/rust/cargo_from_buck:cargo_from_buck` to run autocargo

Reviewed By: aslpavel

Differential Revision: D23849634

fbshipit-source-id: 339fc3976cc9a0b6f10a0538d643b87797e2bc3c
2020-09-26 09:25:29 -07:00
Lukasz Piatkowski
772676a23f third-party/rust: bump third-party code versions
Reviewed By: aslpavel

Differential Revision: https://phabricator.intern.facebook.com/D23930000

fbshipit-source-id: d2f7a926e0a188694254a6f1f77f8408c4b1a0dd
2020-09-26 18:13:40 +02:00
Stanislau Hlebik
b4cf040ef5 mononoke: add version name to working copy equivalence
Summary:
See motivation for the change in D23845720 (5de500bb99).

We'll need to store version name even for commits that weren't rewritten, but that have an equivalent working copy in another repo.

Reviewed By: ikostia

Differential Revision: D23864571

fbshipit-source-id: 408b68c3b0aa9885a9cd248b0b4abc2b87cd4cca
2020-09-25 14:53:13 -07:00
Stanislau Hlebik
4f0b3b3eb5 mononoke: replace a few usages of get_source_target_mover
Summary:
get_source_target_mover likely awaits the same fate as
get_current_mover_DEPRECATED functions i.e. get_source_target_mover will likely
be removed.

This diff just removes a few intances of this function.

Reviewed By: ikostia

Differential Revision: D23929748

fbshipit-source-id: 2ac09da164de3916a552757acf0c39387f6126e4
2020-09-25 14:21:07 -07:00
Stanislau Hlebik
1063f8e44a mononoke: make get_mover and get_reverse_mover functions deprecated
Summary:
get_mover() and get_reverse_mover() functions return the mover for the
"current" version of the commit sync config, which means these are movers for the version
of the config that's used to create the latest commits on master branch.

So this function returns correct mover only for the latest master commit, but
for all other commits it returns an incorrect mover! This is wrong and it
happened to work just by change, and that's why these functions are marked as deprecated
now, and later we'll add functions 'get_mover_by_version()' which could be used to
replace deprecated functions.

Note that the story for get_bookmark_renamer()/get_reverse_bookmark_renamer()
functions seems to be different. If we can always figure out what's the correct
mover for a commit by e.g. look at its parent we can't really do the same for
bookmarks. Because of that I suggest to keep using the current version for
get_bookmark_renamer() function.

Reviewed By: ikostia

Differential Revision: D23929582

fbshipit-source-id: 3e5e9b46224aca0b75cf2d981ea21c4f9a378ba9
2020-09-25 14:21:07 -07:00
Stanislau Hlebik
092875e01d mononoke: remove version from CommitSyncRepos
Summary: Finally remove version_name from CommitSyncRepos. Note that this diff adds a few TODOs that we'd need to fix later.

Reviewed By: ikostia

Differential Revision: D23929010

fbshipit-source-id: c72130af548ac7b26bc20ddaac9a59562cc75e0b
2020-09-25 14:21:07 -07:00
Stanislau Hlebik
99cfa9dcd7 mononoke: remove bookmark_renamer from CommitSyncRepos
Summary: Just as in the previous diff, but this time remove bookmark_renamers from CommitSyncRepos

Reviewed By: ikostia

Differential Revision: D23910295

fbshipit-source-id: 0c2d147057c8d3e0749d5b31ef98ab5022255d95
2020-09-25 11:14:45 -07:00
Stanislau Hlebik
d073b1528d mononoke: remove reverse_mover
Summary: Just as the previous diff, but this time it removes reverse_mover

Reviewed By: ikostia

Differential Revision: D23879509

fbshipit-source-id: ed111ca2d106120229c4facc0bb2435913c27966
2020-09-25 11:14:44 -07:00
Stanislau Hlebik
e05cee0352 mononoke: remove mover from CommitSyncRepos
Summary:
This diff starts to use CommitSyncDataProvider introduced in the previous diff
and removes Mover from CommitSyncRepos struct.

Reviewed By: ikostia

Differential Revision: D23878683

fbshipit-source-id: 0d54f889781aebe4726b3388343a87df783c17d4
2020-09-25 11:14:44 -07:00
Stanislau Hlebik
f2a7850686 mononoke: add CommitSyncDataProvider
Summary:
As described in D23845720 (5de500bb99) we are doing a pretty significant change in the
CommitSyncer. Previously it stored static Movers and BookmarkRenamers, but it
needs to change and they would need to fetch config from LiveCommitSyncConfig.

Unfortunately we already have a bunch of tests that create weird movers that
would be very hard to model via LiveCommitSyncConfig. So we have 2 options:

1) delete or rewrite all these tests
2) Create a wrapper that would return a mover/bookmark renamers.

Option #2 is preferable, and that's what this diff does. In production it would
use LiveCommitSyncConfig, but it also let's tests specify whatever weird movers
they need.

Reviewed By: ikostia

Differential Revision: D23909432

fbshipit-source-id: 83fb627812f625e07f7e40044e2f69274cd2d768
2020-09-25 11:14:44 -07:00
Stanislau Hlebik
eb6326c176 mononoke: update live commit sync config tests
Summary:
Our configerator configs store both "current" mapping version and also they
store all versions that were used before.
These integration tests were updating just current version, but weren't
updating "all" versions. This is incorrect but it worked by accident.
But it will stop working in the next diffs, so  this diff fixes it

Reviewed By: ikostia

Differential Revision: D23908970

fbshipit-source-id: 10f96bd02987d9195aff4855241efbd9a065a761
2020-09-25 06:54:22 -07:00
Kostia Balytskyi
a68af80723 commit_rewriting: make sync_commit accept CandidateSelectionHint
Summary:
A higher-level goal is to provide an interface for the manual remediation of
various xrepo-sync blockages. The nature of a candidate selection is such that
it may fail if the hint is not sufficient to decide which remapping changeset
is the best candidate. This is especially true about the `Only` hint variant:
it is designed to fail when there's more than one candidate. But even with
bookmark ancestorship hints, there are corner cases when the algorithm cannot
make a decision (as well as there may just be bugs in the algorithm). These
cases should be **extremely** rare. Nevertheless, we want to be able to unblock
ourselves. To do so, it is proposed to acccept parent selection hints in the `xrepo-lookup` scs
method. By default, it will use `Only` as a hint and be semantically equivalent
to the current behavior. But we'll provide CLI options to select other hints.

In order to make this work, we need the `sync_commit` method of the
`CommitSyncer` to accept hints too.

Reviewed By: StanislavGlebik

Differential Revision: D23913216

fbshipit-source-id: 05e1ff99cd2c6522829a6e8569040b226600af60
2020-09-25 06:42:29 -07:00
Kostia Balytskyi
759d9778a4 commit_rewriting: make unsafe_sync_commit[_pushrebase] use CandidateSelectionHints
Summary:
This diff adds the use of candidate selection hints to `cross_repo_sync` code sights, which need to query `CommitSyncOutcome` in the small-to-large direction. Specifically: `unsafe_sync_commit` and `unsafe_sync_commit_pushrebase` are the two main functions.

One will now get `CandidateSelectionHint` from the callsight (most notably: `push_redirector`), the other one will build a bookmark-based hint itself.

Reviewed By: StanislavGlebik

Differential Revision: D23715259

fbshipit-source-id: 3f4924f1337b09f3762cc050c4017c5d2bd6cab6
2020-09-24 11:32:07 -07:00
Durham Goode
c80cdf1f49 treemanifest: enable treemanifest.useruststore=True for most tests
Summary:
The remaining test failures are mostly around bundle support, which
I'll fix in a later diff.

Reviewed By: quark-zju

Differential Revision: D23664037

fbshipit-source-id: 2bdde3cb4fcded6e0cf3afdc23269662544821df
2020-09-24 09:46:59 -07:00
Jan Mazur
40cfc97379 adding per repo ACL checking
Summary:
ConnectionSecurityChecker now supports per repository ACL checking.

PermissionCheckers are created in constructor for each repo.
Later when there is a need to check permissions, they're retrieved using a hash map.

Reviewed By: HarveyHunt

Differential Revision: D23678515

fbshipit-source-id: 3d2880fc9df137872ea64a47636f1142d0b36fc1
2020-09-24 08:12:35 -07:00
Stanislau Hlebik
4a1351f333 mononoke: configure TestLiveCommitSyncConfig
Summary:
Previously we had just an empty TestLiveCommitSyncConfig in tests. Since we are
not using it at all right now, it was fine, but we are planning to start using
it later. To do that let's configure TestLiveCommitSyncConfig so that it's not
empty but actually stores a real content.

Reviewed By: ikostia

Differential Revision: D23903579

fbshipit-source-id: af05a377f730c1824b03327749e6f824361e23e2
2020-09-24 07:58:30 -07:00
Stanislau Hlebik
93b2919443 mononoke: use live_commit_sync_config in crossrepo admin
Summary:
At the moment we have a weird setup where cross repo sync configuration is
stored in both live commit sync configuration and in normal mononoke config.
The latter is deprecated, however there are still a few parts of the codebase
that rely on that. This diff fixes one place

Reviewed By: ikostia

Differential Revision: D23903578

fbshipit-source-id: 2bf4b3d17c34fe2eb6330cd862f7b0f5cd6ffa40
2020-09-24 07:58:30 -07:00
Stanislau Hlebik
fc47d6089b mononoke: remove get_mover() usage from commit_validator
Summary:
In D23845720 (5de500bb99) I described what changes we need to make in our commit syncer. One
part of it is that we should remove get_mover() method, as this method always
uses current version of commit sync map even, and that's incorrect.

This diff removes it from commit validator

Reviewed By: ikostia

Differential Revision: D23864350

fbshipit-source-id: 3f650a32835dda9f82949002d63b52cc36cf04e0
2020-09-24 07:58:30 -07:00
Stanislau Hlebik
609c2ac257 mononoke: add another optimization for getbundle
Summary:
D23599866 (54d43b7f95) added an optimization for getbundle that reduces cpu usage when a new
commit with log generation number is added. I.e. the case like this

```
O
|
O
..
   O <- new commit, low generation number
   |
  ...
```

Unfortunately this optimization doesn't help with the case where a new repo is
merged into master

```
O  <- also new commit, but generationo number is high!
| \
..  O <- new commit, low generation number, but it's not in "heads" parameter
    |
    |
    O
  ...
```

The merge commit actually has a high generation number, but it's p2 has a low
generation number, so it causes the same issue with high cpu usage.

This diff adds a second optimization ( :( ) that should help with the shortcoming of the first one. See comments for more details.

Reviewed By: ikostia

Differential Revision: D23824204

fbshipit-source-id: 8f647f1813d2662e41325829d05def633372c140
2020-09-24 07:52:40 -07:00
Thomas Orozco
c4ea8bb15a mononoke: never block when writing to logger() server-side & remove hgcli/fdio
Summary:
This takes johansglock's D23757705 one step further, and gets rid of the
`Wait<...>` wrapper we use to synchronously write to stderr in our logging on
the Mononoke Server side.

This should be fine because We send very little logs to the client, so just
buffering them seems like it won't really hurt, and even if we were writing a
log, it certainly would hurt less than blocking our runtime threads into an
interruptible wait.

A problem is that we actually use this in hgcli, where we want to read from our
stdin and write to our stdout / stderr. Rather than port all this stuff, this
diff updates hgcli to just use Tokio's abstractions for stdink, stdout, and
stderr. I ported the various buffer sizes we use to use there in here (I think
we should buffer less from the server though — 50000 buffers is a lot).

I did however update this to write to `std::io::stderr()` instead of an async
stream for this. I think it's fine considering:

- Internally, Tokio also uses `std:io::stderr()` which has a lock on writing.
- We hardly write anything anyway

Reviewed By: StanislavGlebik

Differential Revision: D23762062

fbshipit-source-id: c8d5330b0735d47b6de00e1a54aee4fed97db6b0
2020-09-24 06:58:34 -07:00
Stanislau Hlebik
f6d3fc1fd7 mononoke: bump the timeouts for getpack
Summary:
There were a few instances of timed out getpack requests on ovrsource.
Example: https://fburl.com/sandcastle/yylr1w3v
Let's bump the timeout to unblock them.

Reviewed By: krallin

Differential Revision: D23900374

fbshipit-source-id: 3ee6e2d4f6b6ed12cd0c1516c686a03c87fa7cb4
2020-09-24 06:23:23 -07:00
Stanislau Hlebik
5de500bb99 mononoke: passing LiveCommitSyncConfig all the way to CommitSyncer
Summary:
CommitSyncer is a struct that we use to remap a commit from one repo to another. It uses commit sync map to figure out which paths need to be changed. Commit sync mapping might change, and each commit sync mapping has a version associated with it.

At the moment CommitSyncer doesn't work correctly if a commit sync mapping is changed. Consider the following DAG

```
large repo

A' <- remapped with mapping V1
|
O  B' <- remapped with mapping V1
|  /
...

small repo

A
|
O  B
|  /
...
```

We have commit A and B from a small repo remapped into a large repo into commits A' and B'. They were remapped with commit sync mapping V1, which for example remaps files in "dir/" into "smallrepo/dir".

Now let's say we start to use a new mapping v2 which remaps "dir/" into "otherdir/". After this point every commit will be created with new mapping. But this is incorrect - if we create a commit on top of B in a small repo that touches "dir/file.txt" then it will be remapped into "otherdir/file.txt" in the large repo, even though every other file is still in "smallrepo/dir"!

The fix for this issue is to always use the same mapping as commit parent was using (there are a few tricky cases with merge commits and commits with no parents, but those will be dealt with separately).

This diff is the first step - it threads through LiveCommitSyncConfig all the way to the CommitSyncer object, so that CommitSyncer can always fetch whatever mapping it needs.

Reviewed By: ikostia

Differential Revision: D23845720

fbshipit-source-id: 555cc31fd4ce09f0a6fa2869bfcee2c7cdfbcc61
2020-09-24 05:58:24 -07:00
Stanislau Hlebik
0754074f63 mononoke: do not read common bookmarks from commit sync config
Summary:
Our current megarepo configuration is in a bit of a mess:
1) We have LiveCommitSyncConfig, which fetches the latest version of configs
from configerator and should be used in all cases
2) However we still have an old commit that's stored in mononoke config. It
shouldn't really be used at all.

Unfortunately there are a few places where #2 is still used. This diff removes
one of them.

Reviewed By: ikostia

Differential Revision: D23845297

fbshipit-source-id: aa2d591223cc4b8fe5ef264147457fcb3d1faad7
2020-09-24 03:31:45 -07:00
Meyer Jacobs
75105421ce edenapi: Hide edenapi wire types from externally visible API
Summary:
Introduce separate wire types to allow protocol evolution and client API changes to happen independently.

* Duplicate `*Request`, `*Entry`, `Key`, `Parents`, `RepoPathBuf`, `HgId`, and `revisionstore_types::Metadata` types into the `wire` module. The versions in the `wire` module are required to have proper `serde` annotations, `Serialize` / `Deserialize` implementations, etc. These have been removed from the original structs.
* Introduce infallible conversions from "API types" to "wire types" with the `ToWire` trait and fallible conversions from "wire types" to "API types" with the `ToApi`. API -> wire conversions should never fail in a binary that builds succesfully, but wire -> API conversions can fail in the case that the server and client are using different versions of the library. This will cause, for instance, a newly-introduced enum variant used by the client to be deserialized into the catch-all `Unknown` variant on the server, which won't generally have a corresponding representation in the API type.
* Cleanup: remove `*Response` types, which are no longer used anywhere.
* Introduce a `map` method on `Fetch` struct which allows a fallible conversion function to be used to convert a `Fetch<T>` to a `Fetch<U>`. This function is used in the edenapi client implementation to convert from wire types to API types.
* Modify `edenapi_server` to convert from API types to wire types.
* Modify `edenapi_cli` to convert back to wire types before serializing responses to disk.
* Modify `make_req` to use `ToWire` for converting API structs from the `json` module to wire structs.
* Modify `read_res` to use `ToApi` to convert deserialized wire types to API types with the necessary methods for investigating the contents (`.data()`, primarily). It will print an error message to stderr if it encounters a wire type which cannot be converted into the corresponding API type.
* Add some documentation about protocol conventions to the root of the `wire` module.

Reviewed By: kulshrax

Differential Revision: D23224705

fbshipit-source-id: 88f8addc403f3a8da3cde2aeee765899a826446d
2020-09-23 17:27:08 -07:00
Lukas Piatkowski
eea2b564a8 mononoke/s3blob: remove it from OSS (#62)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/62

This diff fixes OSS Mononoke build.

Reviewed By: HarveyHunt

Differential Revision: D23852016

fbshipit-source-id: 90371149a3566efdd5653b4ba5098dad81357ef2
2020-09-23 06:38:03 -07:00
Stanislau Hlebik
a47464f60d mononoke: remove create_commit_syncer_from_matches
Summary:
At the moment CommitSyncConfig can be set in two ways:
1) Set in the normal mononoke config. That means that config can be updated
only after a service is restarted. This is an outdated way, and won't be used
in prod.
2) Set in separate config which can be updated on demand. This is what we are
planning to use in production.

create_commit_syncer_from_matches was used to build a CommitSyncer object via
normal mononoke config (i.e. outdated option #1). According to the comments it
was done so that we can read configs from the disk instead of configerator, but
this doesn't make sense because you already can read configerator configs
from disk. So create_commit_syncer_from_matches doesn't look particularly
useful, and besides it also make further refactorings harder. Let's remove it.

Reviewed By: ikostia

Differential Revision: D23811090

fbshipit-source-id: 114d88d9d9207c831d98dfa1cbb9e8ede5adeb1d
2020-09-23 04:30:41 -07:00
Kostia Balytskyi
c56f417c60 commit_rewriting: add new CommitSyncOutcome queries
Summary:
There's a [flaw](https://fb.workplace.com/groups/scm.mononoke/permalink/1220069065022333) in the current `synced_commit_mapping` data model. In a nutshell, the flaw is in the assumption that the `RewrtittenAs` relationship is `1:1`, while in fact it is `1:n` with `n` on the large repo side.

To address this flaw I propose to:
- relax the DB constraints to represent the semantically correct model
- select all the synced candidates from the DB
- for places in code, which require a single mapping for a candidate, use the provided hint to resolve any ambiguity

More concretely:
- instead of a single `CommitSyncOutcome` struct, I propose to have the "canonical" `PluralCommitSyncOutcome` and the "resolved" `CommitSyncOutcome`
- every variant of `PluralCommitSyncOutcome` that is not `RewrittenAs` just maps to an identical variant of `CommitSyncOutcome`
- have a `CandidateSelectionHint` passed from the clients, which would help resolve `PluralCommitSyncOutcome::RewrittenAs` into a `CommitSyncOutcome::RewrittenAs`
- if the hint does not help to resolve `PluralCommitSyncOutcome::RewrittenAs` into an unambiguous `CommitSyncOutcome::RewrittenAs`, just fail the request and require human intervention to deal with things
- within the hint, have for the following variants for the resolution algorithm:
  - `Only` which fails the resolution if there's more than one candidate
  - `Exact` behaves like `Only` if there's one candidate, otherwise selects a provided candidate
  - `OnlyOr(Ancestor|Descendant)Of(Commit|Bookmark)` behave like `Only` if there's one candidate, otherwise select a candidate in the expected topological relationship

Note some important decisions, that may be surprising at first:
- if there's just one candidate, resolutions with all types of hints succeed, even if this candidate does not fit the hint otherwise (for example, if the hint is `Exact(A)`, and the list of candidates is `[B]`, the resolution succeeds.
- for bookmark-related hints, if the bookmark does not exist at the time of resolution, the hint just "downgrades" itself to be `Only`

Both of these emphasize the fact that if the mapping has only one `RewrittenAs` candidate for a given changeset, the behavior does not change.

Reviewed By: StanislavGlebik

Differential Revision: D23670180

fbshipit-source-id: 1cee1f65fc8020e0ae8a7da789b2532d2e436b77
2020-09-22 10:27:27 -07:00
Alex Hornby
d107b28d52 mononoke: SomeFailedOthersNone should not consider write mostly blobstores None if all other stores Error
Summary: SomeFailedOthersNone should not consider write mostly blobstores None if all other stores Error

Reviewed By: farnz

Differential Revision: D23840334

fbshipit-source-id: 9838bead6fec0d5f920e4a788387025d0dacf80b
2020-09-22 09:35:38 -07:00
Alex Hornby
d3a94e0a70 mononoke: Add a test for SomeFailedOthersNone when write mostly blobstore is None
Summary: Add a test for SomeFailedOthersNone when write mostly blobstore is None

Reviewed By: farnz

Differential Revision: D23840685

fbshipit-source-id: 81834663169b3a522b9c08e0a36f0b91354916c7
2020-09-22 09:35:38 -07:00
Stanislau Hlebik
9e05331b1c mononoke: add validation subcommand for megarepo tooling
Summary:
Let's add a command that validates that the created catchup commit is correct.
For now it validates that unodes are the same between catchup commit and commit
that we are merging in.

Later we can add more invariants that we want to check.

Reviewed By: krallin

Differential Revision: D23782369

fbshipit-source-id: 61d19aa73777d5fbb3e1b127bdcf39f5e6309b52
2020-09-22 06:10:39 -07:00
Alex Hornby
d3a32701a6 mononoke: add error context to file content scrub
Summary: Add error context to file content scrub so that we can tell if an Error has propagated via the scrub stream loading.

Reviewed By: StanislavGlebik

Differential Revision: D23838144

fbshipit-source-id: 40a8a090510959cab1020182c19076b8a3317b1b
2020-09-22 05:26:23 -07:00
Egor Tkachenko
4d0ae8ae41 Added S3 blobstore
Summary:
Implemented S3 blobstore
Isilon implements S3 as 1:1 mapping into filesystem, and it limits the maximum number of blobs in the single directory. To overcome it lets shard the keys using base64 encoding and making 2 level dir structure with 2 chars dir names.

Reviewed By: krallin

Differential Revision: D23562541

fbshipit-source-id: c87aca2410381a07babb191cbd8cf28233556e03
2020-09-22 04:15:34 -07:00
Viet Hung Nguyen
d94fae3c4d mononoke/repo_import: add check for additional setup steps
Summary:
When running the repo import tool, it's possible that we need to do additional setup steps before being able to run the tool, which otherwise would only come up when we run it.
Firstly, if the repo we import into doesn't have a callsign (e.g. FBS, WWW...), but we want to check Phabricator, our tool would hang when checking Phabricator, because we need the callsign for checking. Therefore, we need to inform the user to set the callsign for the repo.
Secondly, in case the repo push-redirects to a larger repo, we generate a bookmark for the commits imported into the large. However, we need to inform the Phabricator team to include the large repo's bookmark before we can import the commits, because this bookmark publishes the imported commits on Phabricator.
This diff adds a subcommand to check these additional steps, so we wouldn't find these out during the actual import run.

Reviewed By: StanislavGlebik

Differential Revision: D23783462

fbshipit-source-id: 3cdf4035548213d8cee9717fb985c22741a6749b
2020-09-22 01:24:10 -07:00
Stanislau Hlebik
ff6237ba4a mononoke: refactor cross_repo_sync_test a bit
Summary:
In the later diffs we are going to change how CommitSyncer is initialized. In
order to make it simpler let's refactor cross_repo_sync_test to move
CommitSyncer creation in a single function.

There are a few tests that have very peculiar initialization - for example they
have movers that fail. For those tests I combined the new function for creation
of CommitSyncer with manual initialization of CommitSyncRepos struct.

Reviewed By: krallin

Differential Revision: D23811507

fbshipit-source-id: 682ab30aa09c9189fcd02850a19f1ddf021c0329
2020-09-22 01:13:28 -07:00
Lukas Piatkowski
0f8e20df5b mononoke/integration tests: fix returning different output in OSS cases in tests (#60)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/60

For the tests that output different data to stdout in OSS vs FB create helpers that remove the differences.

Reviewed By: farnz

Differential Revision: D23814134

fbshipit-source-id: c6656528021c9a90b98e3c89a9bbe8c5178c6919
2020-09-21 09:39:18 -07:00
Mark Thomas
2600860e69 scsc: implement land-stack and test stack landing via the service
Summary:
Add `scsc land-stack` to facilitate testing of stack landing via the source control service.
Use this to test that landing of stacks works.

Reviewed By: aslpavel

Differential Revision: D23813366

fbshipit-source-id: 1f7b682fa5e33a232cb1da5c702a703223658942
2020-09-21 08:39:13 -07:00
Mark Thomas
78b943019a mononoke_api: most bookmark movements errors are request errors
Summary:
Update the conversion of `BookmarkMovementError` to `MononokeError` to reflect
that most movement errors are caused by invalid requests.

Reviewed By: aslpavel

Differential Revision: D23814794

fbshipit-source-id: 48503353aaae7b3cd03e5221a8ad014eef2e9414
2020-09-21 08:39:12 -07:00