Commit Graph

77 Commits

Author SHA1 Message Date
Stanislau Hlebik
5ef7ba764b mononoke: do not check non-prefix free paths and verify_config earlier
Summary:
1) Turned out it's possible to have non-prefix free paths in aosp manifests. So
we have to remove this check for now
2) also let's verify config earlier so that we can return an error to the user
faster

Differential Revision: D29335602

fbshipit-source-id: 3dd72d63a370515eca5d356b3b98bb2ac2245aee
2021-06-25 09:26:33 -07:00
Thomas Orozco
8c83bd9a1c third-party/rust: update Tokio to 1.7.1
Summary: There is a regression in 1.7.0 (which we're on at the moment) so we might as well update.

Reviewed By: zertosh, farnz

Differential Revision: D29358047

fbshipit-source-id: 226393d79c165455d27f7a09b14b40c6a30d96d3
2021-06-25 06:17:41 -07:00
Stanislau Hlebik
3c14f3c20b mononoke: fix symlink handling in megarepo_api
Summary:
Path should be relative to the symlink path, not to the repo root. This diff
fixes it

Reviewed By: farnz

Differential Revision: D29327682

fbshipit-source-id: a51161a8039a88263fe941562f2c2134aa5d4fef
2021-06-23 04:20:33 -07:00
Andres Suarez
fc37fea20c Update itertools 0.8.2 to 0.10.1
Reviewed By: dtolnay

Differential Revision: D29286012

fbshipit-source-id: 6923c0b750692e6932e85fd539b076b172ff43b7
2021-06-22 04:09:00 -07:00
Andrew Gallagher
05cf7acd77 object-0.25.3: patch SHT_GNU_versym entsize fix
Summary:
Pull in a patch which fixes writing out an incorrect entsize for the
`SHT_GNU_versym` section:
ddbae72082

Reviewed By: igorsugak

Differential Revision: D29248208

fbshipit-source-id: 90bbaa179df79e817e3eaa846ecfef5c1236073a
2021-06-21 09:31:49 -07:00
Andres Suarez
845128485c Update bytecount
Reviewed By: dtolnay

Differential Revision: D29213998

fbshipit-source-id: 92e7a9de9e3d03f04b92a77e16fa0e37428fe2fb
2021-06-17 19:50:32 -07:00
Davide Cavalca
b82c5672fc Update several rust crate versions
Summary: Update versions for several of the crates we depend on.

Reviewed By: danobi

Differential Revision: D29165283

fbshipit-source-id: baaa9fa106b7dad000f93d2eefa95867ac46e5a1
2021-06-17 16:38:19 -07:00
CodemodService Bot
4c4dfd45ad Daily common/rust/cargo_from_buck/bin/autocargo
Reviewed By: krallin

Differential Revision: D29158387

fbshipit-source-id: 48a0b590e01083d762bbed2b7e272cbefc72641f
2021-06-16 04:50:15 -07:00
Alex Hornby
4457092322 rust: revert zstd crates
Summary: revert the zstd crates back to previous version

Reviewed By: johansglock

Differential Revision: D29038514

fbshipit-source-id: 3cbc31203052034bca428441d5514557311b86ae
2021-06-11 04:39:54 -07:00
Stanislau Hlebik
2029d295e9 mononoke: fix validation failure when copyfile is used
Summary:
Turned out we still don't process copyfile attribute correctly. copyfile
creates two overrides like
{
  "copyfile source" -> default prefix + "/copyfile source"
  "copyfile source" -> "destination"
}

However we also have a check that validates that there no paths (that includes
default path, overrides, linkfiles etc) that are prefixes of each other. And
this check fails in the copyfile case, even though the path maps to exactly the
same path as if default prefix was applied.

Let's fix it. Also note that we haven't seen this failure in the integration
test because we didn't run verify_paths in tests. This diff fixes it as well.

Reviewed By: mitrandir77

Differential Revision: D28992456

fbshipit-source-id: 5fd993914b189cf768ba03010194b1c26026f7a8
2021-06-09 08:15:09 -07:00
Alex Hornby
f89dbebae8 rust: update zstd bindings to 1.5.0
Summary: Update to latest version.  This includes a patch to async-compression crate from [my PR updating it](https://github.com/Nemo157/async-compression/pull/125), I will remove once the crate is released.

Reviewed By: mitrandir77

Differential Revision: D28897019

fbshipit-source-id: 07c72f2880e7f8b85097837d084178c6625e77be
2021-06-08 07:57:29 -07:00
Mateusz Kwapich
98f21e7cb2 add support for syncing merge commits
Reviewed By: StanislavGlebik

Differential Revision: D28887334

fbshipit-source-id: 909a3948df75312767dda8d2f184c0a885a56962
2021-06-08 05:49:01 -07:00
Mateusz Kwapich
59fc317881 add support for copyfiles in test util
Summary: I need it for test in next diff

Reviewed By: StanislavGlebik

Differential Revision: D28959433

fbshipit-source-id: c67ca7eec03f94425332e446f6f97038edff598d
2021-06-08 05:49:01 -07:00
Mateusz Kwapich
eb0290d82a extract last_synced_commit to method
Summary:
Summar:
I'll be using it more in the next diff, so why not have it in it's own method.

Reviewed By: StanislavGlebik

Differential Revision: D28887333

fbshipit-source-id: 35accb495a577e1c01ec8114fc60acf38ed11fee
2021-06-08 05:49:01 -07:00
Mateusz Kwapich
f29792433d add a way to reorder parents during rewrite
Summary:
When syncing merge commits with two parents it would be nice if it was the first parent that comes from the unified branch. In **case of octopus merges** we really don't want
the parent in unified branch to be third (that would turn the sync into
non-forward move!). Let's add a way to tell the commit rewriter which parent
needs to be first.

Reviewed By: farnz

Differential Revision: D28885488

fbshipit-source-id: 57a081ce2d285ba2b6d6d98110cd1c64a241548e
2021-06-08 05:49:01 -07:00
Mateusz Kwapich
fed6a478a8 move create_single_move_commit to common
Summary: I'm planning to reuse it in syncing merge commits.

Reviewed By: farnz

Differential Revision: D28885489

fbshipit-source-id: 6035c0e7290f137b723b73e656b73d4f78e2da9d
2021-06-08 05:49:01 -07:00
CodemodService Bot
254d2a37ad Daily common/rust/cargo_from_buck/bin/autocargo
Reviewed By: krallin

Differential Revision: D28928316

fbshipit-source-id: 6da6c9a5321d722a3dfd816b49f3994df98c7471
2021-06-07 02:19:59 -07:00
Mateusz Kwapich
d2530263b3 obtain repo without doing ACL checks
Summary:
The worker should be able to process the requests from the queue no matter
which repo it is and what are it ACLs. It's during the request scheduling when
we should check the identity of the entity scheduling request.

Reviewed By: StanislavGlebik

Differential Revision: D28866807

fbshipit-source-id: 5d57eb9ba86e10d477be5cfc51dfb8f62ea16b9e
2021-06-03 12:32:54 -07:00
Stanislau Hlebik
530f8279b8 mononoke: put the name of the source in the move and merge commits
Summary: This makes it easier to understand what each move and merge commits are for.

Reviewed By: mitrandir77

Differential Revision: D28839677

fbshipit-source-id: 1a42205c164224b64c773cff80b690b251a48381
2021-06-03 05:24:40 -07:00
Stanislau Hlebik
12969d5738 mononoke: derive data in add_sync_target
Summary:
This is a precaution. add_sync_target can create a very branchy repository, and
I'm not sure how well Mononoke is going to handle deriving of these commits by
all mononoke hosts at once (in particular, I'm worried about traversal that has
to be done by all hosts in parallel). In theory it should work fine, but
deriving data during add_sync_target call should be a reasonable thing to do
anyway.

While working on that I noticed that "git" derived data is not  supported by derived data utils, and it was causing test failures. I don't think there's any reason to not have TreeHandle in derived data utils, so I'm adding it now.

Reviewed By: farnz

Differential Revision: D28831052

fbshipit-source-id: 5f60ac5b93d2c38b4afa0f725c6908edc8b98b18
2021-06-03 02:23:15 -07:00
Robin Håkanson
31fb330fc7 Consistent and unique source_name
Summary:
source_name to be unique even if the same git-repo and project name is mapped several times in the same manifest.

source_name need to match between all the different places we use it, `add_target_config, sync_changeset, changesets_to_merge`  we where not consistent.

Reviewed By: StanislavGlebik

Differential Revision: D28845869

fbshipit-source-id: 54e96dcdeaf22ec68f626e9c30e5e60c54ec149b
2021-06-02 15:03:59 -07:00
Stanislau Hlebik
56107af712 mononoke: create move commits in parallel
Summary:
We are going to create quite a lot of move commits at the same time, and it can
be slow. Let's instead create them in parallel, and then call
`save_bonsai_changesets` for all the commits in one go.

Reviewed By: mitrandir77

Differential Revision: D28795525

fbshipit-source-id: f6b6420c2fe30bb98680ac7e25412c55c99883e0
2021-06-02 07:59:55 -07:00
Stanislau Hlebik
631d21ec95 mononoke: create a stack of merge commits
Summary:
Previously add sync target method was creating a single merge commit. That
means that we might create a bonsai commit with hundreds of parents. This is
not ideal, because mercurial can only work correctly with 2 parents - for
bonsai changeset with 3 parents or more mercurial file histories might be lost.

So instead of creating a single giant merge commit let's create a stack of
merge commits.

Reviewed By: mitrandir77

Differential Revision: D28792581

fbshipit-source-id: 2f8ff6b49db29c4692b7385f1d1ab57986075d57
2021-06-02 07:59:55 -07:00
Stanislau Hlebik
2c63981029 aosp megarepo: validate commits that are passed to add_sync_target
Summary:
Basically do validations that are described in [source_control.thrift
file](https://www.internalfb.com/code/fbsource/[9f147c38ea74f1c6482b99cfd1edd6103d5bd3db]/fbcode/eden/mononoke/scs/if/source_control.thrift?lines=965-975).

Reviewed By: mitrandir77

Differential Revision: D28712729

fbshipit-source-id: 7c55116e4ac875961ded82d6708af56d14a1bf79
2021-06-02 07:59:55 -07:00
Mateusz Kwapich
1089e0bfec allow the async worker to process requests concurrently
Reviewed By: StanislavGlebik

Differential Revision: D28796403

fbshipit-source-id: 38f8cc1071ff80aeb61ddfa160d41c68dc685ca2
2021-06-02 01:40:52 -07:00
Mateusz Kwapich
342298d6c9 return the newly created changeteset id from megarepo methods
Summary:
This fixes the potential race condition in megarepo methods where the bookmark
is updated between executing the actual method and returning the current
bookmark value

Reviewed By: StanislavGlebik

Differential Revision: D28796099

fbshipit-source-id: 472f9bbcfafe1c2eb78c62ccf88d149b5157b646
2021-06-02 01:40:52 -07:00
Mateusz Kwapich
3a33d340e1 return bookmark value from megarepo thrift methods
Summary: This replicates D28679134 (f9a712d618) to actual worker methods.

Reviewed By: StanislavGlebik

Differential Revision: D28759936

fbshipit-source-id: 5d834a9e9e19126788f66c9eff11e0bc1fd06180
2021-06-02 01:40:52 -07:00
Mateusz Kwapich
b163dc98a9 change the return format of poll requests to include the request result
Summary:
Until now we had no way of distinguishing the following two situations:
 * request failed and the returned error represents this failure
 * pooling request failed, the state of actual request is unknown (it might not have even finish yet!)

This diff changes the returned structure to provide the union of error and
response. This has also an upside of simplifying code as the thrift result is
**exactly** what we store in our blobstore.

Reviewed By: StanislavGlebik

Differential Revision: D28747624

fbshipit-source-id: 60473d1491a8c8a016838ec9b2fea0939af10079
2021-06-02 01:40:52 -07:00
Mateusz Kwapich
9302c5a18a use thrift datastructures to serialize errors
Summary:
For some reason the async requests errors were stored in blobstore as strings.
We already have datastructures to properly store them without information loss:
the actual thrfit exceptions that are going the be returned to the end user, we
can't use them directly but we can create structs that with the same structure
so the casting between them will be trivial.

This diff changes what we store. Unfortunately we still deserialize to
MononokeError and serialize back to thrift on pooling. The rest of this diff
stack will deal with that.

Reviewed By: StanislavGlebik

Differential Revision: D28747623

fbshipit-source-id: 7506f1a29220b49482f40d1db8e6b552dabd679a
2021-06-02 01:40:52 -07:00
Stanislau Hlebik
2b44a543e9 aosp megarepo: move tests to a separate file
Summary: Tests take too much space - let's move it to a separate file.

Reviewed By: mitrandir77

Differential Revision: D28712730

fbshipit-source-id: 904afc965b43b21438cb939260967a6057939c59
2021-06-01 02:26:05 -07:00
Stanislau Hlebik
a33a631c3c mononoke: add a verification that checks conflicting files
Summary:
This diff adds a verification that checks that there are no two source files that
remap to the same file in target.

Reviewed By: mitrandir77

Differential Revision: D28709871

fbshipit-source-id: 9b407d223d1d431f2a28031c70b982630c97bdbf
2021-06-01 02:26:05 -07:00
Stanislau Hlebik
4b6f506d2d mononoke: add support for adding linkfiles in add_sync_target
Summary:
Linkfiles are supported by grepo tool - this is a symlink to a file in a sub
git repo.

Previously add_sync_target ignored them - let's fix it now.

Reviewed By: mitrandir77

Differential Revision: D28704032

fbshipit-source-id: 49e66200c0ce8c46d6fb7d81d5f948a5842a064c
2021-06-01 01:14:48 -07:00
Mateusz Kwapich
3de5377b06 introduce async_requests_worker
Reviewed By: StanislavGlebik

Differential Revision: D28606342

fbshipit-source-id: d33441155a325c4d87f720f0e7c342de25b047db
2021-05-27 02:40:11 -07:00
Mateusz Kwapich
c027bba90d add request complete operation
Summary:
An operation that takes a result of computations and saves it so it can be
polled.

Reviewed By: krallin

Differential Revision: D28606343

fbshipit-source-id: 4fdd48f40812c55842669ea3f62865fc8244f6cc
2021-05-27 02:40:11 -07:00
Mateusz Kwapich
54cf93cc70 dequeue_stream
Summary:
This abstracts the constant poolling for new items that megarepo workers will
be doing.

Reviewed By: krallin

Differential Revision: D28606344

fbshipit-source-id: 159c78c207956bcf893ffb68f7f7e93fc2426c8b
2021-05-27 02:40:11 -07:00
Mateusz Kwapich
e6219d521c dequeue operation
Summary: a dequeue operation abstracts popping a request from the queue for processing

Reviewed By: krallin

Differential Revision: D28606339

fbshipit-source-id: d8eba568eab7b6751e422cd11e8ffa5bcb7712b0
2021-05-27 02:40:11 -07:00
Mateusz Kwapich
e0f2ba0808 remove old params and result types
Summary: let's remove dead code.

Reviewed By: krallin

Differential Revision: D28606340

fbshipit-source-id: 1c5479817aa90fed6c76d9fa61b220099941378c
2021-05-27 02:40:11 -07:00
Mateusz Kwapich
86b30a75fa migrate to use new params and responses types
Summary: This diff switches megarepo_api to use the types created in the previous diffs

Reviewed By: krallin

Differential Revision: D28606338

fbshipit-source-id: c048f274395239528b3a0280172dd21052055111
2021-05-27 02:40:11 -07:00
Mateusz Kwapich
fe4014dcc3 add new types for storing params and responses
Summary:
Instead of storing params separate types for each type of request let's store
them in a single union type. This is going to simplify things and improve the
type safety (as we will no longer need to trust in the "request_type" string
store in sql to safely deserialize the type).

Reviewed By: krallin

Differential Revision: D28606341

fbshipit-source-id: cfa8ee15213e6582891906e326d0e258c3a918a1
2021-05-27 02:40:11 -07:00
Mateusz Kwapich
25f87d2c9d add claim_and_get_new_request operation
Summary: This operation is primary way of getting new jobs from queue to tailer.

Reviewed By: krallin

Differential Revision: D28441669

fbshipit-source-id: e4563d74d537d826ad4eba654fe583ea55aee974
2021-05-27 02:40:11 -07:00
Mateusz Kwapich
0c7e361e8d extract row_to_entry to a function
Summary: We do the same thing in many places which isn't great for code readability.

Reviewed By: krallin

Differential Revision: D28441674

fbshipit-source-id: bec69d3bc8a000ac9442020f5054e5c79b3392de
2021-05-27 02:40:10 -07:00
Mateusz Kwapich
5ae2777ca7 fix typo
Reviewed By: krallin

Differential Revision: D28441672

fbshipit-source-id: b4600589997a5493351c80a693fc868e86f0e5c9
2021-05-27 02:40:10 -07:00
Stanislau Hlebik
18718da651 mononoke: implement add_sync_target
Summary:
This is the very first version of add_sync_target method. It's very naive - it
just creates a single merge commit, and it doesn't handle all the necessary
functionality (e.g. linkfiles) and it doesn't do all the necessary checks yet.
TODOs show the missing functionality.

However this implementation it should be good enough as the first version, and
we can continue to extend it.

Reviewed By: mitrandir77

Differential Revision: D28677365

fbshipit-source-id: a8af6b92ced285ce4d012843f591d5c29584669d
2021-05-26 07:26:59 -07:00
Stanislau Hlebik
17a9a29f21 mononoke: move find_repo_by_id to a common trait
Summary: It will be used in the next diffs, let's move it to a common file

Reviewed By: mitrandir77

Differential Revision: D28675768

fbshipit-source-id: 78c21e378053a157d09ee9d032576a434a52c912
2021-05-26 07:26:59 -07:00
Stanislau Hlebik
0ddd4f616a mononoke: move megarepo test utils to a separate file
Summary: They will be used in the next diffs

Reviewed By: mitrandir77

Differential Revision: D28675756

fbshipit-source-id: 2f41191cb83921fb3ff3374c0ccb7a884b7b3a25
2021-05-26 07:26:59 -07:00
Stanislau Hlebik
27ba85afdd mononoke: implement test method for add_sync_target_with_config
Reviewed By: mitrandir77

Differential Revision: D28638072

fbshipit-source-id: a37828656aaccfc6928d3fd5c49a210202a708a1
2021-05-26 04:51:29 -07:00
Mateusz Kwapich
7f0144d872 add claimed_by to requests table
Summary:
For debugging and better error messages it would be nice to know who worked on
a given request.

I'll do AOSC schema change once accepted.

Reviewed By: krallin

Differential Revision: D28441673

fbshipit-source-id: ba146d7f43dde26d9433f76af7fe982da14b5b82
2021-05-25 09:11:43 -07:00
Mateusz Kwapich
fb901786da add repo and bookmark to the async requests table
Summary:
Those will be used for two purposes:
 * to limit a scope of given tailer to just given repo (this way we could use
   different tailer binaries for different repos or disable processing for a
   single repo etc...)
 * to enforce a single in-flight request per repo (to prevent client from
   accidentally scheduling duplicate requests etc...)

I'll do AOSC schema change once accepted.

Reviewed By: krallin

Differential Revision: D28441670

fbshipit-source-id: 7b35a1c7034707d7cf54220c559edd6e03f430c3
2021-05-25 09:11:43 -07:00
Mateusz Kwapich
be32915b9b move the queue to its own module
Summary: I want to put more things in the async_requests crate.

Reviewed By: krallin

Differential Revision: D28441671

fbshipit-source-id: 19233c2c5b697cc1e27107cd9904666baf8f10b7
2021-05-25 09:11:43 -07:00
Stanislau Hlebik
e9ec3955c5 mononoke: add a simple test for sync changeset
Summary:
Simple test that syncs a single commit from a source to a target.

A few notes
1) I want to use test Mononoke instance, but I can't initialize them in another
crate because of cfg(test). I removed cfg(test) to make it possible.
2) I initialized megarepo mapping in TestRepoFactory so that all tables
were in the same db. It's not strictly necessary, but makes initialization a bit simpler.

Reviewed By: mitrandir77

Differential Revision: D28444865

fbshipit-source-id: f39c917806709606ce8e5a1c1158f186d239d8b8
2021-05-18 07:37:56 -07:00