BigW Consortium Gitlab
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.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
blob_viewer | Loading commit data... | |
ci | Loading commit data... | |
clusters | Loading commit data... | |
concerns | Loading commit data... | |
conversational_development_index | Loading commit data... | |
cycle_analytics | Loading commit data... | |
diff_viewer | Loading commit data... | |
hooks | Loading commit data... | |
issue | Loading commit data... | |
members | Loading commit data... | |
merge_request | Loading commit data... | |
network | Loading commit data... | |
project_services | Loading commit data... | |
protected_branch | Loading commit data... | |
ability_spec.rb | Loading commit data... | |
abuse_report_spec.rb | Loading commit data... | |
appearance_spec.rb | Loading commit data... | |
application_setting_spec.rb | Loading commit data... | |
award_emoji_spec.rb | Loading commit data... | |
blob_spec.rb | Loading commit data... | |
board_spec.rb | Loading commit data... | |
broadcast_message_spec.rb | Loading commit data... | |
chat_name_spec.rb | Loading commit data... | |
chat_team_spec.rb | Loading commit data... | |
commit_range_spec.rb | Loading commit data... | |
commit_spec.rb | Loading commit data... | |
commit_status_spec.rb | Loading commit data... | |
compare_spec.rb | Loading commit data... | |
container_repository_spec.rb | Loading commit data... | |
deploy_key_spec.rb | Loading commit data... | |
deploy_keys_project_spec.rb | Loading commit data... | |
deployment_spec.rb | Loading commit data... | |
diff_discussion_spec.rb | Loading commit data... | |
diff_note_spec.rb | Loading commit data... | |
discussion_spec.rb | Loading commit data... | |
email_spec.rb | Loading commit data... | |
environment_spec.rb | Loading commit data... | |
event_collection_spec.rb | Loading commit data... | |
event_spec.rb | Loading commit data... | |
external_issue_spec.rb | Loading commit data... | |
fork_network_member_spec.rb | Loading commit data... | |
fork_network_spec.rb | Loading commit data... | |
forked_project_link_spec.rb | Loading commit data... | |
generic_commit_status_spec.rb | Loading commit data... | |
global_milestone_spec.rb | Loading commit data... | |
gpg_key_spec.rb | Loading commit data... | |
gpg_key_subkey_spec.rb | Loading commit data... | |
gpg_signature_spec.rb | Loading commit data... | |
group_custom_attribute_spec.rb | Loading commit data... | |
group_label_spec.rb | Loading commit data... | |
group_milestone_spec.rb | Loading commit data... | |
group_spec.rb | Loading commit data... | |
guest_spec.rb | Loading commit data... | |
identity_spec.rb | Loading commit data... | |
instance_configuration_spec.rb | Loading commit data... | |
issue_collection_spec.rb | Loading commit data... | |
issue_spec.rb | Loading commit data... | |
key_spec.rb | Loading commit data... | |
label_link_spec.rb | Loading commit data... | |
label_priority_spec.rb | Loading commit data... | |
label_spec.rb | Loading commit data... | |
legacy_diff_discussion_spec.rb | Loading commit data... | |
lfs_objects_project_spec.rb | Loading commit data... | |
list_spec.rb | Loading commit data... | |
member_spec.rb | Loading commit data... | |
merge_request_diff_commit_spec.rb | Loading commit data... | |
merge_request_diff_file_spec.rb | Loading commit data... | |
merge_request_diff_spec.rb | Loading commit data... | |
merge_request_spec.rb | Loading commit data... | |
milestone_spec.rb | Loading commit data... | |
namespace_spec.rb | Loading commit data... | |
note_spec.rb | Loading commit data... | |
notification_setting_spec.rb | Loading commit data... | |
pages_domain_spec.rb | Loading commit data... | |
personal_access_token_spec.rb | Loading commit data... | |
project_authorization_spec.rb | Loading commit data... | |
project_auto_devops_spec.rb | Loading commit data... | |
project_custom_attribute_spec.rb | Loading commit data... | |
project_feature_spec.rb | Loading commit data... | |
project_group_link_spec.rb | Loading commit data... | |
project_label_spec.rb | Loading commit data... | |
project_snippet_spec.rb | Loading commit data... | |
project_spec.rb | Loading commit data... | |
project_statistics_spec.rb | Loading commit data... | |
project_team_spec.rb | Loading commit data... | |
project_wiki_spec.rb | Loading commit data... | |
protectable_dropdown_spec.rb | Loading commit data... | |
protected_branch_spec.rb | Loading commit data... | |
protected_tag_spec.rb | Loading commit data... | |
push_event_payload_spec.rb | Loading commit data... | |
push_event_spec.rb | Loading commit data... | |
redirect_route_spec.rb | Loading commit data... | |
release_spec.rb | Loading commit data... | |
repository_spec.rb | Loading commit data... | |
route_spec.rb | Loading commit data... | |
sent_notification_spec.rb | Loading commit data... | |
service_spec.rb | Loading commit data... | |
snippet_blob_spec.rb | Loading commit data... | |
snippet_spec.rb | Loading commit data... | |
spam_log_spec.rb | Loading commit data... | |
subscription_spec.rb | Loading commit data... | |
system_note_metadata_spec.rb | Loading commit data... | |
timelog_spec.rb | Loading commit data... | |
todo_spec.rb | Loading commit data... | |
tree_spec.rb | Loading commit data... | |
trending_project_spec.rb | Loading commit data... | |
upload_spec.rb | Loading commit data... | |
user_agent_detail_spec.rb | Loading commit data... | |
user_custom_attribute_spec.rb | Loading commit data... | |
user_spec.rb | Loading commit data... | |
wiki_directory_spec.rb | Loading commit data... | |
wiki_page_spec.rb | Loading commit data... |