316.md 20.4 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
# Geo Nodes API

> 原文:[https://docs.gitlab.com/ee/api/geo_nodes.html](https://docs.gitlab.com/ee/api/geo_nodes.html)

*   [Create a new Geo node](#create-a-new-geo-node)
*   [Retrieve configuration about all Geo nodes](#retrieve-configuration-about-all-geo-nodes)
*   [Retrieve configuration about a specific Geo node](#retrieve-configuration-about-a-specific-geo-node)
*   [Edit a Geo node](#edit-a-geo-node)
*   [Delete a Geo node](#delete-a-geo-node)
*   [Repair a Geo node](#repair-a-geo-node)
*   [Retrieve status about all Geo nodes](#retrieve-status-about-all-geo-nodes)
*   [Retrieve status about a specific Geo node](#retrieve-status-about-a-specific-geo-node)
*   [Retrieve project sync or verification failures that occurred on the current node](#retrieve-project-sync-or-verification-failures-that-occurred-on-the-current-node)

# Geo Nodes API[](#geo-nodes-api-premium-only "Permalink")

为了与地理节点端点进行交互,您需要以管理员身份进行身份验证.

## Create a new Geo node[](#create-a-new-geo-node "Permalink")

创建一个新的地理节点.

```
POST /geo_nodes 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/geo_nodes" \
     --request POST \
     -d "name=himynameissomething" \
     -d "url=https://another-node.example.com/" 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `primary` | boolean | no | 指定此节点是否为主节点. 默认为 false. |
| `enabled` | boolean | no | 指示是否启用地理节点的标志. 默认为 true. |
| `name` | string | yes | 地理节点的唯一标识符. 必须匹配`geo_node_name`如果在设定`gitlab.rb` ,否则必须匹配`external_url` |
| `url` | string | yes | Geo 节点的面向用户的 URL. |
| `internal_url` | string | no | 在主节点上定义的 URL,辅助节点应使用该 URL 与之联系. 如果未设置,则返回`url` . |
| `files_max_capacity` | integer | no | 控制此辅助节点的 LFS /附件回填的最大并发性. 默认为 10 |
| `repos_max_capacity` | integer | no | 控制此辅助节点的存储库回填的最大并发性. 默认为 25. |
| `verification_max_capacity` | integer | no | 控制此节点的存储库验证的最大并发性. 默认为 100. |
| `container_repositories_max_capacity` | integer | no | 控制此节点的容器存储库同步的最大并发性. 默认为 10 |
| `sync_object_storage` | boolean | no | 指示辅助 Geo 节点是否将复制对象存储中的 Blob 的标志. 默认为 false. |
| `selective_sync_type` | string | no | Limit syncing to only specific groups or shards. Valid values: `"namespaces"`, `"shards"`, or `null`. |
| `selective_sync_shards` | array | no | 如果`selective_sync_type` == `shards` ,则同步项目的存储库存储. |
| `selective_sync_namespace_ids` | array | no | 如果`selective_sync_type` == `namespaces` ,则应同步的组的 ID. |
| `minimum_reverification_interval` | integer | no | 存储库验证有效的时间间隔(以天为单位). 一旦过期,它将被重新验证. 在辅助节点上进行设置时,这无效. |

响应示例:

```
{  "id":  3,  "name":  "Test Node 1",  "url":  "https://secondary.example.com/",  "internal_url":  "https://secondary.example.com/",  "primary":  false,  "enabled":  true,  "current":  false,  "files_max_capacity":  10,  "repos_max_capacity":  25,  "verification_max_capacity":  100,  "selective_sync_type":  "namespaces",  "selective_sync_shards":  [],  "selective_sync_namespace_ids":  [1,  25],  "minimum_reverification_interval":  7,  "container_repositories_max_capacity":  10,  "sync_object_storage":  false,  "clone_protocol":  "http",  "web_edit_url":  "https://primary.example.com/admin/geo/nodes/3/edit",  "web_geo_projects_url":  "http://secondary.example.com/admin/geo/projects",  "_links":  {  "self":  "https://primary.example.com/api/v4/geo_nodes/3",  "status":  "https://primary.example.com/api/v4/geo_nodes/3/status",  "repair":  "https://primary.example.com/api/v4/geo_nodes/3/repair"  }  } 
```

## Retrieve configuration about all Geo nodes[](#retrieve-configuration-about-all-geo-nodes "Permalink")

```
GET /geo_nodes 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/geo_nodes" 
```

响应示例:

```
[  {  "id":  1,  "name":  "us-node",  "url":  "https://primary.example.com/",  "internal_url":  "https://internal.example.com/",  "primary":  true,  "enabled":  true,  "current":  true,  "files_max_capacity":  10,  "repos_max_capacity":  25,  "container_repositories_max_capacity":  10,  "verification_max_capacity":  100,  "selective_sync_type":  "namespaces",  "selective_sync_shards":  [],  "selective_sync_namespace_ids":  [1,  25],  "minimum_reverification_interval":  7,  "clone_protocol":  "http",  "web_edit_url":  "https://primary.example.com/admin/geo/nodes/1/edit",  "_links":  {  "self":  "https://primary.example.com/api/v4/geo_nodes/1",  "status":"https://primary.example.com/api/v4/geo_nodes/1/status",  "repair":"https://primary.example.com/api/v4/geo_nodes/1/repair"  }  },  {  "id":  2,  "name":  "cn-node",  "url":  "https://secondary.example.com/",  "internal_url":  "https://secondary.example.com/",  "primary":  false,  "enabled":  true,  "current":  false,  "files_max_capacity":  10,  "repos_max_capacity":  25,  "container_repositories_max_capacity":  10,  "verification_max_capacity":  100,  "selective_sync_type":  "namespaces",  "selective_sync_shards":  [],  "selective_sync_namespace_ids":  [1,  25],  "minimum_reverification_interval":  7,  "sync_object_storage":  true,  "clone_protocol":  "http",  "web_edit_url":  "https://primary.example.com/admin/geo/nodes/2/edit",  "web_geo_projects_url":  "https://secondary.example.com/admin/geo/projects",  "_links":  {  "self":"https://primary.example.com/api/v4/geo_nodes/2",  "status":"https://primary.example.com/api/v4/geo_nodes/2/status",  "repair":"https://primary.example.com/api/v4/geo_nodes/2/repair"  }  }  ] 
```

## Retrieve configuration about a specific Geo node[](#retrieve-configuration-about-a-specific-geo-node "Permalink")

```
GET /geo_nodes/:id 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/geo_nodes/1" 
```

响应示例:

```
{  "id":  1,  "name":  "us-node",  "url":  "https://primary.example.com/",  "internal_url":  "https://primary.example.com/",  "primary":  true,  "enabled":  true,  "current":  true,  "files_max_capacity":  10,  "repos_max_capacity":  25,  "container_repositories_max_capacity":  10,  "verification_max_capacity":  100,  "selective_sync_type":  "namespaces",  "selective_sync_shards":  [],  "selective_sync_namespace_ids":  [1,  25],  "minimum_reverification_interval":  7,  "clone_protocol":  "http",  "web_edit_url":  "https://primary.example.com/admin/geo/nodes/1/edit",  "_links":  {  "self":  "https://primary.example.com/api/v4/geo_nodes/1",  "status":"https://primary.example.com/api/v4/geo_nodes/1/status",  "repair":"https://primary.example.com/api/v4/geo_nodes/1/repair"  }  } 
```

## Edit a Geo node[](#edit-a-geo-node "Permalink")

更新现有地理节点的设置.

*这只能在主要的地理节点上运行.*

```
PUT /geo_nodes/:id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer | yes | 地理位置节点的 ID. |
| `enabled` | boolean | no | 指示是否启用地理节点的标志. |
| `name` | string | yes | 地理节点的唯一标识符. 必须匹配`geo_node_name`如果在设定`gitlab.rb` ,否则必须匹配`external_url` . |
| `url` | string | yes | Geo 节点的面向用户的 URL. |
| `internal_url` | string | no | 在主节点上定义的 URL,辅助节点应使用该 URL 与之联系. 如果未设置,则返回`url` . |
| `files_max_capacity` | integer | no | 控制此辅助节点的 LFS /附件回填的最大并发性. |
| `repos_max_capacity` | integer | no | 控制此辅助节点的存储库回填的最大并发性. |
| `verification_max_capacity` | integer | no | 控制此节点的最大并发验证. |
| `container_repositories_max_capacity` | integer | no | 控制此节点的容器存储库同步的最大并发性. |
| `sync_object_storage` | boolean | no | 指示辅助 Geo 节点是否将复制对象存储中的 Blob 的标志. |
| `selective_sync_type` | string | no | 将同步限制为仅特定的组或碎片. 有效值: `"namespaces"``"shards"``null` . |
| `selective_sync_shards` | array | no | 如果`selective_sync_type` == `shards` ,则同步项目的存储库存储. |
| `selective_sync_namespace_ids` | array | no | 如果`selective_sync_type` == `namespaces` ,则应同步的组的 ID. |
| `minimum_reverification_interval` | integer | no | 存储库验证有效的时间间隔(以天为单位). 一旦过期,它将被重新验证. 在辅助节点上进行设置时,这无效. |

响应示例:

```
{  "id":  1,  "name":  "cn-node",  "url":  "https://secondary.example.com/",  "internal_url":  "https://secondary.example.com/",  "primary":  false,  "enabled":  true,  "current":  true,  "files_max_capacity":  10,  "repos_max_capacity":  25,  "container_repositories_max_capacity":  10,  "verification_max_capacity":  100,  "selective_sync_type":  "namespaces",  "selective_sync_shards":  [],  "selective_sync_namespace_ids":  [1,  25],  "minimum_reverification_interval":  7,  "sync_object_storage":  true,  "clone_protocol":  "http",  "web_edit_url":  "https://primary.example.com/admin/geo/nodes/2/edit",  "web_geo_projects_url":  "https://secondary.example.com/admin/geo/projects",  "_links":  {  "self":"https://primary.example.com/api/v4/geo_nodes/2",  "status":"https://primary.example.com/api/v4/geo_nodes/2/status",  "repair":"https://primary.example.com/api/v4/geo_nodes/2/repair"  }  } 
```

## Delete a Geo node[](#delete-a-geo-node "Permalink")

删除地理节点.

**注意:**只有 Geo 主节点将接受此请求.

```
DELETE /geo_nodes/:id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer | yes | 地理位置节点的 ID. |

## Repair a Geo node[](#repair-a-geo-node "Permalink")

修复地理节点的 OAuth 身份验证.

*这只能在主要的地理节点上运行.*

```
POST /geo_nodes/:id/repair 
```

响应示例:

```
{  "id":  1,  "name":  "us-node",  "url":  "https://primary.example.com/",  "internal_url":  "https://primary.example.com/",  "primary":  true,  "enabled":  true,  "current":  true,  "files_max_capacity":  10,  "repos_max_capacity":  25,  "container_repositories_max_capacity":  10,  "verification_max_capacity":  100,  "clone_protocol":  "http",  "web_edit_url":  "https://primary.example.com/admin/geo/nodes/1/edit",  "_links":  {  "self":  "https://primary.example.com/api/v4/geo_nodes/1",  "status":"https://primary.example.com/api/v4/geo_nodes/1/status",  "repair":"https://primary.example.com/api/v4/geo_nodes/1/repair"  }  } 
```

## Retrieve status about all Geo nodes[](#retrieve-status-about-all-geo-nodes "Permalink")

```
GET /geo_nodes/status 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/geo_nodes/status" 
```

响应示例:

```
[  {  "geo_node_id":  1,  "healthy":  true,  "health":  "Healthy",  "health_status":  "Healthy",  "missing_oauth_application":  false,  "attachments_count":  1,  "attachments_synced_count":  nil,  "attachments_failed_count":  nil,  "attachments_synced_missing_on_primary_count":  0,  "attachments_synced_in_percentage":  "0.00%",  "db_replication_lag_seconds":  nil,  "lfs_objects_count":  0,  "lfs_objects_synced_count":  nil,  "lfs_objects_failed_count":  nil,  "lfs_objects_synced_missing_on_primary_count":  0,  "lfs_objects_synced_in_percentage":  "0.00%",  "job_artifacts_count":  2,  "job_artifacts_synced_count":  nil,  "job_artifacts_failed_count":  nil,  "job_artifacts_synced_missing_on_primary_count":  0,  "job_artifacts_synced_in_percentage":  "0.00%",  "container_repositories_count":  3,  "container_repositories_synced_count":  nil,  "container_repositories_failed_count":  nil,  "container_repositories_synced_in_percentage":  "0.00%",  "design_repositories_count":  3,  "design_repositories_synced_count":  nil,  "design_repositories_failed_count":  nil,  "design_repositories_synced_in_percentage":  "0.00%",  "projects_count":  41,  "repositories_failed_count":  nil,  "repositories_synced_count":  nil,  "repositories_synced_in_percentage":  "0.00%",  "wikis_failed_count":  nil,  "wikis_synced_count":  nil,  "wikis_synced_in_percentage":  "0.00%",  "replication_slots_count":  1,  "replication_slots_used_count":  1,  "replication_slots_used_in_percentage":  "100.00%",  "replication_slots_max_retained_wal_bytes":  0,  "repositories_checked_count":  20,  "repositories_checked_failed_count":  20,  "repositories_checked_in_percentage":  "100.00%",  "repositories_checksummed_count":  20,  "repositories_checksum_failed_count":  5,  "repositories_checksummed_in_percentage":  "48.78%",  "wikis_checksummed_count":  10,  "wikis_checksum_failed_count":  3,  "wikis_checksummed_in_percentage":  "24.39%",  "repositories_verified_count":  20,  "repositories_verification_failed_count":  5,  "repositories_verified_in_percentage":  "48.78%",  "repositories_checksum_mismatch_count":  3,  "wikis_verified_count":  10,  "wikis_verification_failed_count":  3,  "wikis_verified_in_percentage":  "24.39%",  "wikis_checksum_mismatch_count":  1,  "repositories_retrying_verification_count":  1,  "wikis_retrying_verification_count":  3,  "repositories_checked_count":  7,  "repositories_checked_failed_count":  2,  "repositories_checked_in_percentage":  "17.07%",  "last_event_id":  23,  "last_event_timestamp":  1509681166,  "cursor_last_event_id":  nil,  "cursor_last_event_timestamp":  0,  "last_successful_status_check_timestamp":  1510125024,  "version":  "10.3.0",  "revision":  "33d33a096a",  "package_files_count":  10,  "package_files_checksummed_count":  10,  "package_files_checksum_failed_count":  0,  "package_files_registry_count":  10,  "package_files_synced_count":  6,  "package_files_failed_count":  3  },  {  "geo_node_id":  2,  "healthy":  true,  "health":  "Healthy",  "health_status":  "Healthy",  "missing_oauth_application":  false,  "attachments_count":  1,  "attachments_synced_count":  1,  "attachments_failed_count":  0,  "attachments_synced_missing_on_primary_count":  0,  "attachments_synced_in_percentage":  "100.00%",  "db_replication_lag_seconds":  0,  "lfs_objects_count":  0,  "lfs_objects_synced_count":  0,  "lfs_objects_failed_count":  0,  "lfs_objects_synced_missing_on_primary_count":  0,  "lfs_objects_synced_in_percentage":  "0.00%",  "job_artifacts_count":  2,  "job_artifacts_synced_count":  1,  "job_artifacts_failed_count":  1,  "job_artifacts_synced_missing_on_primary_count":  0,  "job_artifacts_synced_in_percentage":  "50.00%",  "container_repositories_count":  3,  "container_repositories_synced_count":  nil,  "container_repositories_failed_count":  nil,  "container_repositories_synced_in_percentage":  "0.00%",  "design_repositories_count":  3,  "design_repositories_synced_count":  nil,  "design_repositories_failed_count":  nil,  "design_repositories_synced_in_percentage":  "0.00%",  "projects_count":  41,  "repositories_failed_count":  1,  "repositories_synced_count":  40,  "repositories_synced_in_percentage":  "97.56%",  "wikis_failed_count":  0,  "wikis_synced_count":  41,  "wikis_synced_in_percentage":  "100.00%",  "replication_slots_count":  nil,  "replication_slots_used_count":  nil,  "replication_slots_used_in_percentage":  "0.00%",  "replication_slots_max_retained_wal_bytes":  nil,  "repositories_checksummed_count":  20,  "repositories_checksum_failed_count":  5,  "repositories_checksummed_in_percentage":  "48.78%",  "wikis_checksummed_count":  10,  "wikis_checksum_failed_count":  3,  "wikis_checksummed_in_percentage":  "24.39%",  "repositories_verified_count":  20,  "repositories_verification_failed_count":  5,  "repositories_verified_in_percentage":  "48.78%",  "repositories_checksum_mismatch_count":  3,  "wikis_verified_count":  10,  "wikis_verification_failed_count":  3,  "wikis_verified_in_percentage":  "24.39%",  "wikis_checksum_mismatch_count":  1,  "repositories_retrying_verification_count":  4,  "wikis_retrying_verification_count":  2,  "repositories_checked_count":  5,  "repositories_checked_failed_count":  1,  "repositories_checked_in_percentage":  "12.20%",  "last_event_id":  23,  "last_event_timestamp":  1509681166,  "cursor_last_event_id":  23,  "cursor_last_event_timestamp":  1509681166,  "last_successful_status_check_timestamp":  1510125024,  "version":  "10.3.0",  "revision":  "33d33a096a",  "package_files_count":  10,  "package_files_checksummed_count":  10,  "package_files_checksum_failed_count":  0,  "package_files_registry_count":  10,  "package_files_synced_count":  6,  "package_files_failed_count":  3  }  ] 
```

**注意:**在 GitLab 12.0 中,已弃用的字段`wikis_count``repositories_count`被删除. 请改用`projects_count` .

## Retrieve status about a specific Geo node[](#retrieve-status-about-a-specific-geo-node "Permalink")

```
GET /geo_nodes/:id/status 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/geo_nodes/2/status" 
```

响应示例:

```
{  "geo_node_id":  2,  "healthy":  true,  "health":  "Healthy",  "health_status":  "Healthy",  "missing_oauth_application":  false,  "attachments_count":  1,  "attachments_synced_count":  1,  "attachments_failed_count":  0,  "attachments_synced_missing_on_primary_count":  0,  "attachments_synced_in_percentage":  "100.00%",  "db_replication_lag_seconds":  0,  "lfs_objects_count":  0,  "lfs_objects_synced_count":  0,  "lfs_objects_failed_count":  0,  "lfs_objects_synced_missing_on_primary_count":  0,  "lfs_objects_synced_in_percentage":  "0.00%",  "job_artifacts_count":  2,  "job_artifacts_synced_count":  1,  "job_artifacts_failed_count":  1,  "job_artifacts_synced_missing_on_primary_count":  0,  "job_artifacts_synced_in_percentage":  "50.00%",  "container_repositories_count":  3,  "container_repositories_synced_count":  nil,  "container_repositories_failed_count":  nil,  "container_repositories_synced_in_percentage":  "0.00%",  "design_repositories_count":  3,  "design_repositories_synced_count":  nil,  "design_repositories_failed_count":  nil,  "design_repositories_synced_in_percentage":  "0.00%",  "projects_count":  41,  "repositories_failed_count":  1,  "repositories_synced_count":  40,  "repositories_synced_in_percentage":  "97.56%",  "wikis_failed_count":  0,  "wikis_synced_count":  41,  "wikis_synced_in_percentage":  "100.00%",  "replication_slots_count":  nil,  "replication_slots_used_count":  nil,  "replication_slots_used_in_percentage":  "0.00%",  "replication_slots_max_retained_wal_bytes":  nil,  "last_event_id":  23,  "last_event_timestamp":  1509681166,  "cursor_last_event_id":  23,  "cursor_last_event_timestamp":  1509681166,  "last_successful_status_check_timestamp":  1510125268,  "version":  "10.3.0",  "revision":  "33d33a096a"  } 
```

注意: `health_status`参数只能处于"健康"或"不健康"状态,而`health`参数可以为空,"健康"或包含实际错误消息.

**注意:**在 GitLab 12.0 中,已弃用的字段`wikis_count``repositories_count`被删除. 请改用`projects_count` .

## Retrieve project sync or verification failures that occurred on the current node[](#retrieve-project-sync-or-verification-failures-that-occurred-on-the-current-node "Permalink")

这仅适用于辅助节点.

```
GET /geo_nodes/current/failures 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | no | 失败对象的类型( `repository` / `wiki` ) |
| `failure_type` | string | no | 故障类型( `sync` / `checksum_mismatch` / `verification` ) |

该端点使用[分页](README.html#pagination) .

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/geo_nodes/current/failures" 
```

响应示例:

```
[  {  "project_id":  3,  "last_repository_synced_at":  "2017-10-31 14:25:55 UTC",  "last_repository_successful_sync_at":  "2017-10-31 14:26:04 UTC",  "last_wiki_synced_at":  "2017-10-31 14:26:04 UTC",  "last_wiki_successful_sync_at":  "2017-10-31 14:26:11 UTC",  "repository_retry_count":  null,  "wiki_retry_count":  1,  "last_repository_sync_failure":  null,  "last_wiki_sync_failure":  "Error syncing Wiki repository",  "last_repository_verification_failure":  "",  "last_wiki_verification_failure":  "",  "repository_verification_checksum_sha":  "da39a3ee5e6b4b0d32e5bfef9a601890afd80709",  "wiki_verification_checksum_sha":  "da39a3ee5e6b4b0d3255bfef9ef0189aafd80709",  "repository_checksum_mismatch":  false,  "wiki_checksum_mismatch":  false  }  ] 
```