Commit Graph

534 Commits

Author SHA1 Message Date
Douwe Maan 2fbbba9a29 Always return full avatar URL for private/internal groups/projects when asset host is set 2017-11-09 15:40:41 +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
Rémy Coutable 31e3ef93e5 Merge branch 'feature/custom-attributes-on-projects-and-groups' into 'master'
Support custom attributes on groups and projects

See merge request gitlab-org/gitlab-ce!14593
2017-11-07 10:59:38 +00:00
Douwe Maan a10925e1c3 Reallow project paths ending in periods 2017-11-06 14:46:53 +01:00
Markus Koller 6902848a9c
Support custom attributes on projects 2017-11-06 10:51:46 +01:00
Bob Van Landuyt 39d00bddc4 Make sure the settings page renders when root of a fork is deleted 2017-11-03 11:08:36 +01:00
Douwe Maan 682923b79b Merge branch '3674-hashed-storage-attachments' into 'master'
Hashed Storage support for Attachments

See merge request gitlab-org/gitlab-ce!15068
2017-10-31 12:18:47 +00:00
Kamil Trzciński e829d5a084 Merge branch 'add-packagist-project-service' into 'master'
Add Packagist project service

See merge request gitlab-org/gitlab-ce!14493
2017-10-31 11:54:49 +00:00
Gabriel Mazetto 9c41c7ac1e Make `#hashed_storage?` require feature argument 2017-10-31 12:13:48 +01:00
Gabriel Mazetto 6a4534b62f Code Style changes and `hashed_storage?` now receives optional feature 2017-10-31 02:00:40 +01:00
Gabriel Mazetto b19076948d Moved renaming operations to storage layer abstraction
When project storage_version is `2` means attachments are using
hashed storage.
2017-10-27 21:27:17 +02:00
Matt Coleman c207122fd2 Add Packagist project service 2017-10-13 13:42:53 -04:00
Bob Van Landuyt bd8943f5ad Fix spinach features
And several other failures
2017-10-11 14:16:40 +02:00
Bob Van Landuyt 741fb49378 Merge branch 'master' into bvl-group-trees 2017-10-10 17:53:42 +02:00
Bob Van Landuyt 9d1348d668 Move the `ancestors_upto` to `Project` and `Namespace` 2017-10-10 16:55:02 +02:00
Douwe Maan 36ae3bf1ca Merge branch '38245-private-avatars-are-not-cdn-compatible' into 'master'
Resolve "Private Avatars are not CDN compatible"

Closes #38245 and gitlab-com/support-forum#2476

See merge request gitlab-org/gitlab-ce!14443
2017-10-10 12:48:19 +00:00
Tim Zallmann 59c6ddcdef Fix for Lint Error + Upload Test 2017-10-09 17:05:51 +02:00
Douwe Maan 546b18b903 Merge branch 'tc-geo-read-only-idea' into 'master'
Create idea of read-only database

Closes #37534

See merge request gitlab-org/gitlab-ce!14688
2017-10-07 11:01:21 +00:00
Bob Van Landuyt e8ca579d88 Add a project forks spec helper
The helper creates a fork of a project with all provided attributes,
but skipping the creation of the repository on disk.
2017-10-07 11:46:23 +02:00
Bob Van Landuyt 70716a1292 Allow creating merge requests across forks of a project 2017-10-07 11:46:23 +02:00
Kamil Trzciński 5ee20b6375 Merge branch 'master' into '37970-ci-sections-tracking'
# Conflicts:
#   db/schema.rb
2017-10-07 08:07:33 +00:00
Toon Claes d13669716a Create idea of read-only database
In GitLab EE, a GitLab instance can be read-only (e.g. when it's a Geo
secondary node). But in GitLab CE it also might be useful to have the
"read-only" idea around. So port it back to GitLab CE.

Also having the principle of read-only in GitLab CE would hopefully
lead to less errors introduced, doing write operations when there
aren't allowed for read-only calls.

Closes gitlab-org/gitlab-ce#37534.
2017-10-06 22:37:40 +02:00
Shinya Maeda 91e530df24 Merge branch 'master' into feature/sm/35954-create-kubernetes-cluster-on-gke-from-k8s-service 2017-10-06 21:29:03 +09:00
Alessio Caiazza 91f8e734fe
Add CI build trace sections extractor 2017-10-05 15:42:25 +02:00
Zeger-Jan van de Weg 4656283c5c
Gitaly namespace service enabled for GitLab 2017-10-05 14:11:32 +02:00
Bob Van Landuyt b3acd5459c Use `alias_attribute` & `alias_method` to define parent-methods 2017-10-05 13:12:40 +02:00
Kamil Trzcinski 54831bd44b Updated messages and notices 2017-10-04 21:10:08 +02:00
Sean McGivern 0ac06c89e9 Merge branch 'ff_port_from_ee' into 'master'
Move Fast-Forward Merge to CE

See merge request gitlab-org/gitlab-ce!14272
2017-10-03 08:24:31 +00:00
Stan Hu bac2916030 Fix gitlab-rake gitlab:import:repos task
Because of a change in GitLab 9.5.4 to prevent users from assuming control of
a repository already on disk, the import task broke. Imports would fail with
the message, "There is already a repository with that name on disk".

This change skips the validation when the import is done from the
command-line.

Closes #37682
2017-10-02 08:51:37 -07:00
Valery Sizov a0ac2d932c Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into ff_port_from_ee 2017-10-02 13:15:46 +03:00
Jacob Vosmaer e5fecc3a37 Create repositories via Gitaly 2017-09-29 18:27:06 +02:00
Eric Eastwood 3468ca835d Merge branch 'master' into ff_port_from_ee
Conflicts:
	app/models/project.rb
	db/schema.rb
2017-09-28 16:59:49 -05:00
Gabriel Mazetto f4de14d71f
Add support to migrate existing projects to Hashed Storage async 2017-09-28 16:32:14 +01:00
Valery Sizov 19a62632f7 Add spec for Project#merge_method
It should be deleted from EE side when doing CE->EE merge!
2017-09-20 13:31:39 +03:00
Yorick Peterse 3e999684f9
Memoize pipelines for project download buttons
This adds Project#latest_successful_pipeline_for and
Project#latest_successful_pipeline_for_default_branch. The 2nd method
memoizes the result (taking nil values into account) to ensure the
underlying query isn't executed multiple times when viewing a project's
homepage.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/36878#note_40073607
for more information.
2017-09-14 13:20:05 +02:00
Kamil Trzcinski 83c1bb688c Add has_auto_devops_implicitly_disabled 2017-09-07 15:08:51 +02:00
Kamil Trzcinski 632f6ba267 Add tests to cover all introduced changes 2017-09-06 21:00:34 +02:00
Zeger-Jan van de Weg 8189347b49
Merge branch 'master' into zj-auto-devops-table 2017-09-06 15:16:38 +02:00
Rubén Dávila 66cfb901c0 Optimize SQL queries used in Groups::GroupMembersController#create
The following optimizations were performed:

- Add new association to GroupMember and ProjectMember

  This new association will allow us to check if a user is a member of a
  Project or Group through a single query instead of two.

- Optimize retrieving of Members when adding multiple Users
2017-09-05 15:54:07 -05:00
Zeger-Jan van de Weg bcd70c4c46
Incorporate review 2017-09-04 15:44:46 +02:00
Marin Jankovski 28060caa0a
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce 2017-09-01 09:21:18 +02:00
Grzegorz Bizon d5d2497643 Merge branch 'zj-disable-pages-in-subgroups' into 'master'
Don't show references to Pages when not available

Closes #34864

See merge request !13888
2017-08-31 12:59:29 +00:00
Marin Jankovski 7d38df306c
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq 2017-08-31 10:45:28 +02:00
Zeger-Jan van de Weg 04cd47dd5a
Don't show references to Pages when not available
In this instance its subgroups, and given we can't deploy it, we
shouldn't allow it to be shown.

Fixes gitlab-org/gitlab-ce#34864
2017-08-31 09:27:42 +02:00
Lin Jen-Shin 3a4da8ce8b Fix tests 2017-08-28 18:51:23 +08:00
Gabriel Mazetto 8f178c4222 Prevent new / renamed project from using a repository path that already exists on disk
There are some redundancies in the validation steps, and that is to
preserve current error messages behavior

Also few specs have to be changed in order to fix madness in validation
logic.
2017-08-25 20:06:06 +02:00
Lin Jen-Shin 932d32515a Move to Projects::HousecleaningService 2017-08-24 18:58:31 +08:00
Lin Jen-Shin 140ac8d2ad Add changelog and tests 2017-08-23 21:51:21 +08:00
Gabriel Mazetto fb9e059a41 Make sure repository's removal work for legacy and hashed storages 2017-08-22 06:33:20 +02:00
Gabriel Mazetto 02737b8508 Use `@hashed` prefix for hashed paths on disk, to avoid collision with existing ones 2017-08-22 06:33:20 +02:00