群组仓库存储移动 API

  • Tier: 专业版, 旗舰版
  • Offering: 私有化部署

极狐GitLab 群组 Wiki 仓库可以在存储之间移动。此 API 可以帮助您,例如,迁移到 Gitaly 集群 或迁移一个群组 Wiki。此 API 不管理群组中的项目仓库。要安排项目移动,请使用项目仓库存储移动 API

随着极狐GitLab 处理群组仓库存储移动,它会经历不同的状态。state 的值为:

  • initial:记录已创建,但后台作业尚未安排。
  • scheduled:后台作业已安排。
  • started:群组仓库正在复制到目标存储。
  • replicated:群组已被移动。
  • failed:群组仓库复制失败,或校验和不匹配。
  • finished:群组已被移动,源存储上的仓库已被删除。
  • cleanup failed:群组已被移动,但源存储上的仓库无法删除。

为了确保数据完整性,极狐GitLab 在移动期间将群组置于临时只读状态。在此期间,如果用户尝试推送新的提交,他们将收到此消息:

plaintext
The repository is temporarily read-only. Please try again later.

此 API 需要您以管理员身份进行身份验证

API 还可用于移动其他类型的仓库:

检索所有群组仓库存储移动#

plaintext
GET /group_repository_storage_moves

默认情况下,GET 请求一次返回 20 个结果,因为 API 结果是分页的

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/group_repository_storage_moves"

示例响应:

json
1[ 2 { 3 "id": 1, 4 "created_at": "2020-05-07T04:27:17.234Z", 5 "state": "scheduled", 6 "source_storage_name": "default", 7 "destination_storage_name": "storage2", 8 "group": { 9 "id": 283, 10 "web_url": "https://gitlab.example.com/groups/testgroup", 11 "name": "testgroup" 12 } 13 } 14]

检索单个群组的所有仓库存储移动#

要检索单个群组的所有仓库存储移动,您可以使用以下端点:

plaintext
GET /groups/:group_id/repository_storage_moves

默认情况下,GET 请求一次返回 20 个结果,因为 API 结果是分页的

支持的属性:

属性类型必需描述
group_idintegeryes群组的 ID。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/groups/1/repository_storage_moves"

示例响应:

json
1[ 2 { 3 "id": 1, 4 "created_at": "2020-05-07T04:27:17.234Z", 5 "state": "scheduled", 6 "source_storage_name": "default", 7 "destination_storage_name": "storage2", 8 "group": { 9 "id": 283, 10 "web_url": "https://gitlab.example.com/groups/testgroup", 11 "name": "testgroup" 12 } 13 } 14]

获取单个群组仓库存储移动#

要在所有现有仓库存储移动中检索单个仓库存储移动,可以使用以下端点:

plaintext
GET /group_repository_storage_moves/:repository_storage_id

支持的属性:

属性类型必需描述
repository_storage_idintegeryes群组仓库存储移动的 ID。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/group_repository_storage_moves/1"

示例响应:

json
1{ 2 "id": 1, 3 "created_at": "2020-05-07T04:27:17.234Z", 4 "state": "scheduled", 5 "source_storage_name": "default", 6 "destination_storage_name": "storage2", 7 "group": { 8 "id": 283, 9 "web_url": "https://gitlab.example.com/groups/testgroup", 10 "name": "testgroup" 11 } 12}

获取群组的单个仓库存储移动#

给定一个群组,您可以通过以下端点检索该群组的特定仓库存储移动:

plaintext
GET /groups/:group_id/repository_storage_moves/:repository_storage_id

支持的属性:

属性类型必需描述
group_idintegeryes群组的 ID。
repository_storage_idintegeryes群组仓库存储移动的 ID。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/groups/1/repository_storage_moves/1"

示例响应:

json
1{ 2 "id": 1, 3 "created_at": "2020-05-07T04:27:17.234Z", 4 "state": "scheduled", 5 "source_storage_name": "default", 6 "destination_storage_name": "storage2", 7 "group": { 8 "id": 283, 9 "web_url": "https://gitlab.example.com/groups/testgroup", 10 "name": "testgroup" 11 } 12}

为群组安排仓库存储移动#

为群组安排仓库存储移动。此端点:

  • 仅移动群组 Wiki 仓库。
  • 不移动群组中的项目仓库。要安排项目移动,请使用项目仓库存储移动 API。
plaintext
POST /groups/:group_id/repository_storage_moves

支持的属性:

属性类型必需描述
group_idintegeryes群组的 ID。
destination_storage_namestringno目标存储分片的名称。如果未提供,则根据存储权重选择存储。

示例请求:

shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ --header "Content-Type: application/json" \ --data '{"destination_storage_name":"storage2"}' \ --url "https://gitlab.example.com/api/v4/groups/1/repository_storage_moves"

示例响应:

json
1{ 2 "id": 1, 3 "created_at": "2020-05-07T04:27:17.234Z", 4 "state": "scheduled", 5 "source_storage_name": "default", 6 "destination_storage_name": "storage2", 7 "group": { 8 "id": 283, 9 "web_url": "https://gitlab.example.com/groups/testgroup", 10 "name": "testgroup" 11 } 12}

为存储分片上的所有群组安排仓库存储移动#

为存储在源存储分片上的每个群组仓库安排仓库存储移动。此端点一次迁移所有群组。有关更多信息,请参阅移动所有群组

plaintext
POST /group_repository_storage_moves

支持的属性:

属性类型必需描述
source_storage_namestringyes源存储分片的名称。
destination_storage_namestringno目标存储分片的名称。如果未提供,则根据存储权重选择存储。

示例请求:

shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ --header "Content-Type: application/json" \ --data '{"source_storage_name":"default"}' \ --url "https://gitlab.example.com/api/v4/group_repository_storage_moves"

示例响应:

json
{ "message": "202 Accepted" }