Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab GitLab
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 38,038
    • Issues 38,038
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 1,346
    • Merge requests 1,346
  • Requirements
    • Requirements
    • List
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLabGitLab
  • Merge requests
  • !47142

Merged
Created Nov 09, 2020 by James Fargher@proglottis🌴Maintainer2 of 13 tasks completed2/13 tasks

Adds bulk project repository storage move API

  • Overview 74
  • Commits 2
  • Pipelines 37
  • Changes 20

What does this MR do?

Fixes #272554 (closed)

Fixes #227833 (closed)

  • Add a new API to bulk schedule a move for all projects on a storage shard.
  • Not providing a destination will follow the new project storage selection ratios

Manual Testing

Setup gdk.yml:

praefect:
  enabled: true
gitaly:
  storage_count: 4

Rejigger gdk:

$ gdk reconfigre
$ gdk restart

Check where some project is currently stored so we know we'll move at least one:

$ curl -H "PRIVATE_TOKEN: XXXX" http://gdk.test:3000/api/v4/projects/19 | jq
{
  "id": 19,
...
  "repository_storage": "gitaly-3",
...
}

Reconfigure repository weights: Screen_Shot_2020-11-10_at_10.02.29_AM

Initiate the move:

$ curl -X POST -H "PRIVATE_TOKEN: XXXX" -H "Content-Type: application/json" -d '{"source_storage_name": "gitaly-3"}' http://gdk.test:3000/api/v4/project_repository_storage_moves | jq
{
  "message": "202 Accepted"
}

After enough time, check that the project moved:

$ curl -H "PRIVATE_TOKEN: XXXX" http://gdk.test:3000/api/v4/projects/19 | jq
{
  "id": 19,
...
  "repository_storage": "gitaly-1",
...
}

🎉 🎉 🎉

Database

One iteration query:

SELECT "projects".* FROM "projects" WHERE "projects"."id" IN (SELECT "project_repositories"."project_id" FROM "project_repositories" WHERE "project_repositories"."shard_id" = 122 AND "project_repositories"."project_id" >= 16267295 AND "project_repositories"."project_id" < 16277136) 

Plan: https://explain.depesz.com/s/Zxlh

Does this MR meet the acceptance criteria?

Conformity

  • Changelog entry
  • Documentation (if required)
  • Code review guidelines
  • Merge request performance guidelines
  • Style guides
  • Database guides
  • Separation of EE specific content

Availability and Testing

  • Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
  • Tested in all supported browsers
  • Informed Infrastructure department of a default or new setting change, if applicable per definition of done

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited Nov 17, 2020 by Adam Hegyi
Assignee
Assign to
Reviewer
Request review from
13.7
Milestone
13.7 (Past due)
Assign milestone
Time tracking
Source branch: bulk_project_move_api