Commit Graph

141 Commits

Author SHA1 Message Date
Takuya Noguchi 2b6307f6ad Enable RuboCop Style/RegexpLiteral 2018-02-01 02:06:07 +09:00
Ahmad Sherif 1ebb781f6a Migrate Git::Repository#delete_refs to Gitaly
Closes gitaly#967
2018-01-30 23:48:51 +01:00
Jacob Vosmaer (GitLab) 5c2fe2d3d7 Decouple more of Repository from Rugged 2018-01-30 16:21:55 +00:00
Jacob Vosmaer (GitLab) e407c2d18f Don't allow Repository#log with limit zero 2018-01-29 15:27:46 +00:00
Ahmad Sherif 2290b438f4 Fix rubocop offenses introduced in !16623 2018-01-25 20:44:16 +01:00
Robert Speicher af95ba2fb4 Merge branch 'feature/migrate-repo-restorer-to-gitaly' into 'master'
Migrate restoring repo from bundle to Gitaly

Closes gitaly#946

See merge request gitlab-org/gitlab-ce!16623
2018-01-25 19:03:51 +00:00
Jacob Vosmaer (GitLab) 7363aa0b9d Revert "Merge branch 'remove-rugged-walk' into 'master'"
This reverts merge request !16525
2018-01-25 11:03:29 +01:00
Ahmad Sherif 6a28967c14 Migrate restoring repo from bundle to Gitaly
Closes gitaly#946
2018-01-24 19:02:32 +01:00
Ahmad Sherif 24625323a8 Migrate repository bundling to Gitaly
Closes gitaly#929
2018-01-24 12:10:31 +01:00
Jacob Vosmaer (GitLab) fa52038731 Remove Rugged::Walker from Repository#log 2018-01-18 14:05:14 +00:00
Jacob Vosmaer (GitLab) f4de7309ab Remove unused methods from Gitlab::Git 2018-01-17 09:54:27 +00:00
Ahmad Sherif 831019412f Migrate merged_branch_names to Gitaly
Closes gitaly#851
2018-01-11 14:52:15 +01:00
Sean McGivern d42c0ecc02 Merge branch 'gitaly-fetch-internal-remote' into 'master'
Incorporate RemoteService.FetchInternalRemote Gitaly RPC

Closes gitaly#857

See merge request gitlab-org/gitlab-ce!16140
2018-01-08 10:42:35 +00:00
Alejandro Rodríguez 9ff44c2986 Incorporate RemoteService.FetchInternalRemote Gitaly RPC 2018-01-05 15:45:24 -03:00
Lin Jen-Shin (godfat) 33c5630b02 Use --left-right and --max-count for counting diverging commits 2018-01-05 16:52:06 +00:00
Dmitriy Zaporozhets 58a705aaac Merge branch 'ce-gitaly-remote-mirror-prep' into 'master'
[CE] Move git operations for UpdateRemoteMirrorService into Gitlab::Git

See merge request gitlab-org/gitlab-ce!16023
2018-01-04 16:02:22 +00:00
Sean McGivern a0ae886135 Merge branch 'gitaly-merge-nil' into 'master'
Handle Gitaly aborted merge due to branch update

Closes gitaly#854

See merge request gitlab-org/gitlab-ce!16116
2018-01-04 11:01:02 +00:00
Alejandro Rodríguez 1c458d17d7 Move delete_remote_branches from Gitlab::Shell to Gitlab::Git::Repository 2018-01-03 23:07:38 -03:00
Alejandro Rodríguez 43308bd826 Move push_remote_branches from Gitlab::Shell to Gitlab::Git::Repository 2018-01-03 23:06:34 -03:00
Jacob Vosmaer 449b59ec69 Better English 2018-01-03 12:54:47 +01:00
Jacob Vosmaer 8cf0ea4469 Handle Gitaly aborted merge due to branch update 2018-01-03 12:02:37 +01:00
Ahmad Sherif 13932b0b12 Add support for max_count option to Git::Repository#count_commits 2017-12-27 14:16:24 +01:00
Dmitriy Zaporozhets 87bae6d42f Merge branch 'gitaly-remotes' into 'master'
Incorporate Gitaly's RemoteService RPCs

Closes gitaly#852

See merge request gitlab-org/gitlab-ce!16060
2017-12-25 10:43:04 +00:00
Alejandro Rodríguez 2694355bb6 Incorporate Gitaly's RemoteService RPCs 2017-12-22 20:30:08 -03:00
Alejandro Rodríguez 7354c9f75d Remove unused method `remote_exists?` 2017-12-22 20:30:07 -03:00
blackst0ne 27c95364b5 Replace '.team << [user, role]' with 'add_role(user)' in specs 2017-12-22 19:18:28 +11:00
Nick Thomas 4b785df27b
Import gitlab_projects.rb from gitlab-shell
By importing this Ruby code into gitlab-rails (and gitaly-ruby), we avoid
200ms of startup time for each gitlab_projects subprocess we are eliminating.

By not having a gitlab_projects subprocess between gitlab-rails / sidekiq and
any git subprocesses (e.g. for fork_project, fetch_remote, etc, calls), we can
also manage these git processes more cleanly, and avoid sending SIGKILL to them
2017-12-14 16:00:04 +00:00
Robert Speicher 6930fa3102 Merge branch 'gitaly-mirroring-prep' into 'master'
Gitaly mirroring migration prep

Closes gitaly#816

See merge request gitlab-org/gitlab-ce!15775
2017-12-11 20:50:07 +00:00
Zeger-Jan van de Weg 03ac8d5d0b Remove Rugged::Repository#empty? 2017-12-07 15:33:30 +00:00
Alejandro Rodríguez 885a4da208 Add feature flag to use gitaly-ssh mirroring when cloning internal repos
This also allows us to simplify the naming since we can make some
fetching methods private.
2017-12-06 18:41:45 -03:00
Stan Hu 66127221fe Gracefully handle case when repository's root ref does not exist
This was failing regularly with an Error 500 when the API branches endpoint
was used.

Closes #40615
2017-11-30 23:21:44 -08:00
Sean McGivern dd11f0e053 Merge branch 'dm-cleanup-fetch-and-mirror-methods' into 'master'
Clean up repository fetch and mirror methods

See merge request gitlab-org/gitlab-ce!15424
2017-11-23 17:01:47 +00:00
Douwe Maan 0e6beaf50c Clean up repository fetch and mirror methods 2017-11-23 16:59:50 +01:00
Lin Jen-Shin 5951320075 Make sure repository is restored 2017-11-23 18:26:41 +08:00
Lin Jen-Shin 7df1cb528e Move identical merged branch check to merged_branch_names 2017-11-23 18:26:41 +08:00
Douwe Maan 4b78f70fc4 Merge branch 'gitaly-delete-refs' into 'master'
Incorporate Gitaly's RefService.DeleteRefs RPC

Closes gitaly#740

See merge request gitlab-org/gitlab-ce!15460
2017-11-20 15:20:40 +00:00
Alejandro Rodríguez 3f0c9e9708 Fix Gitlab::Git::Repository#remote_tags using unexisting variable 2017-11-20 09:08:09 +00:00
Alejandro Rodríguez 38730a2d07 Incorporate Gitaly's RefService.DeleteRefs RPC 2017-11-17 18:08:50 -03:00
Jacob Vosmaer (GitLab) de301d13bb Prepare Repository#fetch_source_branch for migration 2017-11-10 14:45:23 +00:00
Yorick Peterse 4dfe26cd8b
Rewrite the GitHub importer from scratch
Prior to this MR there were two GitHub related importers:

* Github::Import: the main importer used for GitHub projects
* Gitlab::GithubImport: importer that's somewhat confusingly used for
  importing Gitea projects (apparently they have a compatible API)

This MR renames the Gitea importer to Gitlab::LegacyGithubImport and
introduces a new GitHub importer in the Gitlab::GithubImport namespace.
This new GitHub importer uses Sidekiq for importing multiple resources
in parallel, though it also has the ability to import data sequentially
should this be necessary.

The new code is spread across the following directories:

* lib/gitlab/github_import: this directory contains most of the importer
  code such as the classes used for importing resources.
* app/workers/gitlab/github_import: this directory contains the Sidekiq
  workers, most of which simply use the code from the directory above.
* app/workers/concerns/gitlab/github_import: this directory provides a
  few modules that are included in every GitHub importer worker.

== Stages

The import work is divided into separate stages, with each stage
importing a specific set of data. Stages will schedule the work that
needs to be performed, followed by scheduling a job for the
"AdvanceStageWorker" worker. This worker will periodically check if all
work is completed and schedule the next stage if this is the case. If
work is not yet completed this worker will reschedule itself.

Using this approach we don't have to block threads by calling `sleep()`,
as doing so for large projects could block the thread from doing any
work for many hours.

== Retrying Work

Workers will reschedule themselves whenever necessary. For example,
hitting the GitHub API's rate limit will result in jobs rescheduling
themselves. These jobs are not processed until the rate limit has been
reset.

== User Lookups

Part of the importing process involves looking up user details in the
GitHub API so we can map them to GitLab users. The old importer used
an in-memory cache, but this obviously doesn't work when the work is
spread across different threads.

The new importer uses a Redis cache and makes sure we only perform
API/database calls if absolutely necessary.  Frequently used keys are
refreshed, and lookup misses are also cached; removing the need for
performing API/database calls if we know we don't have the data we're
looking for.

== Performance & Models

The new importer in various places uses raw INSERT statements (as
generated by `Gitlab::Database.bulk_insert`) instead of using Rails
models. This allows us to bypass any validations and callbacks,
drastically reducing the number of SQL queries and Gitaly RPC calls
necessary to import projects.

To ensure the code produces valid data the corresponding tests check if
the produced rows are valid according to the model validation rules.
2017-11-07 23:24:59 +01:00
Sean McGivern 045795d0d9 Merge branch 'remove-ensure-ref-fetched-from-controllers' into 'master'
removed the #ensure_ref_fetched from all controllers

Closes #36061

See merge request gitlab-org/gitlab-ce!15129
2017-11-06 17:10:18 +00:00
Alejandro Rodríguez dea6d054cd Encapsulate git operations for mirroring in Gitlab::Git 2017-11-03 14:33:24 -03:00
Alejandro Rodríguez 88d2517e36 Add `Gitlab::Git::Repository#fetch` command 2017-11-03 14:33:24 -03:00
micael.bergeron cd88fa8f80 removed the #ensure_ref_fetched from all controllers
also, I refactored the MergeRequest#fetch_ref method to express
the side-effect that this method has.

  MergeRequest#fetch_ref -> MergeRequest#fetch_ref!
  Repository#fetch_source_branch -> Repository#fetch_source_branch!
2017-11-03 08:13:11 -04:00
Rémy Coutable 6a5e8f1046 Merge branch 'gitaly-ff-merge' into 'master'
Incorporate Gitaly's OperationService.UserFFBranch RPC

Closes gitaly#693

See merge request gitlab-org/gitlab-ce!15040
2017-11-02 16:11:53 +00:00
Kim Carlbäcker d6066870cc Fix encoding issue with Repository.ls_files 2017-11-02 08:29:03 +00:00
Douwe Maan e65bbc0ca4 Merge branch 'jej/lfs-change-detection' into 'master'
Detect changes to LFS pointers for pruning and integrity check

See merge request gitlab-org/gitlab-ce!14785
2017-11-01 17:33:41 +00:00
James Edwards-Jones fb3f9c6e50 Detect changes to LFS pointers for pruning and integrity check
Gitlab::Git::Blob.batch_lfs_metadata can be used to check for LFS pointers. It uses a lazy enumorator and filters by blob size
2017-11-01 16:41:05 +00:00
Alejandro Rodríguez 37cc50f843 Incorporate Gitaly's OperationService.UserFFBranch RPC 2017-10-31 16:28:09 -03:00
Lin Jen-Shin (godfat) 57d7ed05d9 Fetch the merged branches at once 2017-10-27 15:55:08 +00:00