Allow automatically selecting repository storage on move

What does this MR do?

gitaly#3209 (closed)

When moving project repositories, if destination_storage_name is not provided, use the same logic as Project to assign it. These are currently weighted by an admin configuration page.

Manual Testing

Setup gdk.yml:

praefect:
  enabled: true
gitaly:
  storage_count: 4

Rejigger gdk:

$ gdk reconfigre
$ gdk restart

Check where the project is currently stored:

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

Reconfigure repository weights: Screen_Shot_2020-10-16_at_3.25.34_PM

Initiate the move:

$ curl -X POST -H "PRIVATE_TOKEN: XXXX" -H "Content-Type: application/json" -d '{}' http://gdk.test:3000/api/v4/projects/19/repository_storage_moves | jq
{
  "id": 17,
  "created_at": "2020-10-16T02:28:15.149Z",
  "state": "scheduled",
  "source_storage_name": "default",
  "destination_storage_name": "gitaly-2",
  "project": {
    "id": 19,
    "description": "",
    "name": "Gitaly",
    "name_with_namespace": "Administrator / Gitaly",
    "path": "gitaly",
    "path_with_namespace": "root/gitaly",
    "created_at": "2020-06-29T22:18:29.342Z"
  }
}

gitaly-2 was chosen 🎉

Try again:

$ curl -X POST -H "PRIVATE_TOKEN: XXXX" -H "Content-Type: application/json" -d '{}' http://gdk.test:3000/api/v4/projects/19/repository_storage_moves | jq
{
  "id": 18,
  "created_at": "2020-10-16T02:29:21.260Z",
  "state": "scheduled",
  "source_storage_name": "gitaly-2",
  "destination_storage_name": "gitaly-3",
  "project": {
    "id": 19,
    "description": "",
    "name": "Gitaly",
    "name_with_namespace": "Administrator / Gitaly",
    "path": "gitaly",
    "path_with_namespace": "root/gitaly",
    "created_at": "2020-06-29T22:18:29.342Z"
  }
}

gitaly-3 was chosen 🎉 🎉

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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 by James Fargher

Merge request reports

Loading