Commit graph

22 commits

Author SHA1 Message Date
Jamie Schembri
d32802c76b Fix #49272 - Sanitize git URL in import errors 2018-07-16 12:17:54 +02:00
Francisco Javier López
e8f49b4bee Support LFS objects when creating a project by import 2018-06-06 16:42:18 +00:00
Douwe Maan
b95918dda8
Make error messages even more descriptive 2018-04-02 17:20:18 +02:00
Yorick Peterse
6e242e8223
Replace old GH importer with the parallel importer 2017-11-07 23:25:03 +01: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
Douglas Barbosa Alexandre
517a9f97c7 Does not fetch repository when importing from GitHub on import service 2017-08-07 13:06:13 -03:00
Robert Speicher
72a7b30c9f Change all :empty_project to :project 2017-08-02 17:47:31 -04:00
Gabriel Mazetto
abb878326c Rename many path_with_namespace -> full_path 2017-08-01 07:26:58 +02:00
Rémy Coutable
ddccd24c13 Remove superfluous lib: true, type: redis, service: true, models: true, services: true, no_db: true, api: true
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:53 +02:00
Grzegorz Bizon
0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Maxime Besson
9326d89623
Allow manual bypass of auto_sign_in_with_provider
This commit lets a user bypass the automatic signin on the login form,
in order to login with a technical (admin, etc) account

Closes #3786

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-02 20:00:11 +02:00
Douglas Barbosa Alexandre
bf0717802f Does not remove the GitHub remote when importing from GitHub 2017-04-18 00:22:33 +00:00
Douglas Barbosa Alexandre
6143642a5f Refactoring Projects::ImportService 2017-04-03 15:50:22 -03:00
Douwe Maan
65aafb9917 Merge branch 'ssrf' into 'security'
Protect server against SSRF in project import URLs

See merge request !2068
2017-03-20 18:53:04 -07:00
Ahmad Sherif
6e590af148 Check if repository already exists before trying to re-import it 2016-10-28 11:12:48 +02:00
James Lopez
29141ed3ea fix broken repo 500 errors in UI and added relevant specs 2016-09-29 16:58:14 +02:00
Alejandro Rodríguez
86359ec854 Refactor repository paths handling to allow multiple git mount points 2016-06-29 22:30:31 -04:00
Kamil Trzcinski
13d941e185 Make Omniauth providers specs to not modify global configuration 2016-06-08 16:50:05 +02:00
James Lopez
d9df05e143 fix import service spec 2016-06-02 21:48:27 -04:00
Stan Hu
eede032345 Backport GitHub Enterprise import support from EE
These changes were pulled from GitLab EE to support configuring
an alternative API URL than the default https://api.github.com.
In addition, the `verify_ssl` flag allows users to disable SSL cert
checking.

One modification: add a default `args` option if it does not exist
to avoid breaking existing configurations.
2016-04-26 21:00:55 -07:00
Douglas Barbosa Alexandre
f2005fa566 Flush repository cache before import project data
GitHub Pull Requests importer handle with the repository while
importing data, we need to make sure that the cached values are valid.
2016-04-04 19:35:39 -03:00
Douglas Barbosa Alexandre
6dd88e090e Extract Projects::ImportService service from RepositoryImportWorker 2016-01-25 22:58:30 -02:00