Commit Graph

20 Commits

Author SHA1 Message Date
GitLab Bot b3e461ab0f Add latest changes from gitlab-org/gitlab@master 2022-10-07 00:08:16 +00:00
GitLab Bot ca520489ff Add latest changes from gitlab-org/gitlab@master 2022-06-15 03:09:07 +00:00
GitLab Bot 17dffb6c51 Add latest changes from gitlab-org/gitlab@master 2022-05-05 06:08:22 +00:00
GitLab Bot 50d66f5ece Add latest changes from gitlab-org/gitlab@master 2021-04-01 12:08:56 +00:00
GitLab Bot a662b146ac Add latest changes from gitlab-org/gitlab@master 2020-11-05 12:09:05 +00:00
GitLab Bot eb004dc626 Add latest changes from gitlab-org/gitlab@master 2020-10-27 12:08:33 +00:00
GitLab Bot bdca097916 Add latest changes from gitlab-org/gitlab@master 2020-08-11 03:11:00 +00:00
GitLab Bot c59765a50a Add latest changes from gitlab-org/gitlab@master 2020-06-24 18:09:03 +00:00
GitLab Bot 927df95cc4 Add latest changes from gitlab-org/gitlab@master 2020-05-15 12:08:28 +00:00
GitLab Bot 154b9bae14 Add latest changes from gitlab-org/gitlab@master 2020-03-17 21:09:16 +00:00
GitLab Bot cbfe03ae04 Add latest changes from gitlab-org/gitlab@master 2020-03-16 12:09:12 +00:00
GitLab Bot a89cb5cbdd Add latest changes from gitlab-org/gitlab@master 2020-02-06 21:08:48 +00:00
GitLab Bot 784fae4b9d Add latest changes from gitlab-org/gitlab@master 2019-12-12 12:07:33 +00:00
GitLab Bot 26121e3bcd Add latest changes from gitlab-org/gitlab@master 2019-11-24 12:06:34 +00:00
Jason Goodman 7ecffe2987 Show upcoming status for releases
Add released_at field to releases API
Add released_at column to releases table
Return releases to the API sorted by released_at
2019-07-03 09:12:15 +00:00
John Kristensen 265e52bb80 Improve the gitea importer test
The changes to the tests to support ignoring Gitea pull requests comments were
a bit of a hack. The suggestions provided by Ash McKenzie in
gitlab-org/gitlab-ce!29521 make things a bit more flexible if any future
changes need to be made to the tests.

The changes made to ignore
2019-06-14 06:17:51 +00:00
John Kristensen e47d9b3d04 Don't import pull request comments from Gitea repos
The Gitea API does not provide the following API endpoint for pull request
comments:

  /api/v1/repos/{owner}/{repo}/pulls/comments

When the importer attempts to request this endpoint it receives a '404
Not Found' error which causes the import to fail. By skipping any
attempts to import pull requests comments from Gitea we can ensure that
the import can complete successfully.
2019-06-12 00:52:54 +00:00
Shinya Maeda 8f1e96c89b Add spec for Release API
Add spec for all release API - GET, POST, PUT, DELETE.
Also, fixes some minior bugs.
2018-12-31 14:35:57 +09:00
Tiago Botelho 4bd8a427d4
Removes all the irrelevant import related code and columns
Clears the import related columns and code from the Project
model over to the ProjectImportState model
2018-11-27 12:58:13 +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