Commit 9a8a17ad authored by Michael Kozono's avatar Michael Kozono

Merge branch 'selective-sync-params-create-geo' into 'master'

Add selective sync support to Geo Nodes API create endpoint

Closes #4731

See merge request gitlab-org/gitlab!23729
parents 1c4e95cb 1711c39b
---
title: Add selective sync support to Geo Nodes API create endpoint
merge_request: 23729
author: Rajendra Kadam
type: added
...@@ -30,6 +30,10 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" https://primary.example.com/a ...@@ -30,6 +30,10 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" https://primary.example.com/a
| `verification_max_capacity` | integer | no | Control the maximum concurrency of repository verification for this node. Defaults to 100. | | `verification_max_capacity` | integer | no | Control the maximum concurrency of repository verification for this node. Defaults to 100. |
| `container_repositories_max_capacity` | integer | no | Control the maximum concurrency of container repository sync for this node. Defaults to 10. | | `container_repositories_max_capacity` | integer | no | Control the maximum concurrency of container repository sync for this node. Defaults to 10. |
| `sync_object_storage` | boolean | no | Flag indicating if the secondary Geo node will replicate blobs in Object Storage. Defaults to false. | | `sync_object_storage` | boolean | no | Flag indicating if the secondary Geo node will replicate blobs in Object Storage. Defaults to 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 | The repository storage for the projects synced if `selective_sync_type` == `shards`. |
| `selective_sync_namespace_ids` | array | no | The IDs of groups that should be synced, if `selective_sync_type` == `namespaces`. |
| `minimum_reverification_interval` | integer | no | The interval (in days) in which the repository verification is valid. Once expired, it will be reverified. This has no effect when set on a secondary node. |
Example response: Example response:
...@@ -45,6 +49,10 @@ Example response: ...@@ -45,6 +49,10 @@ Example response:
"files_max_capacity": 10, "files_max_capacity": 10,
"repos_max_capacity": 25, "repos_max_capacity": 25,
"verification_max_capacity": 100, "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, "container_repositories_max_capacity": 10,
"sync_object_storage": false, "sync_object_storage": false,
"clone_protocol": "http", "clone_protocol": "http",
......
...@@ -6,7 +6,7 @@ module Geo ...@@ -6,7 +6,7 @@ module Geo
def initialize(params) def initialize(params)
@params = params.dup @params = params.dup
@params[:namespace_ids] = @params[:namespace_ids].to_s.split(',') @params[:namespace_ids] = @params[:namespace_ids].to_s.split(',') if @params[:namespace_ids].is_a? String
end end
def execute def execute
......
...@@ -27,6 +27,10 @@ module API ...@@ -27,6 +27,10 @@ module API
optional :verification_max_capacity, type: Integer, desc: 'Control the maximum concurrency of repository verification for this node. Defaults to 100.' optional :verification_max_capacity, type: Integer, desc: 'Control the maximum concurrency of repository verification for this node. Defaults to 100.'
optional :container_repositories_max_capacity, type: Integer, desc: 'Control the maximum concurrency of container repository sync for this node. Defaults to 10.' optional :container_repositories_max_capacity, type: Integer, desc: 'Control the maximum concurrency of container repository sync for this node. Defaults to 10.'
optional :sync_object_storage, type: Boolean, desc: 'Flag indicating if the secondary Geo node will replicate blobs in Object Storage. Defaults to false.' optional :sync_object_storage, type: Boolean, desc: 'Flag indicating if the secondary Geo node will replicate blobs in Object Storage. Defaults to false.'
optional :selective_sync_type, type: String, desc: 'Limit syncing to only specific groups, or shards. Valid values: `"namespaces"`, `"shards"`, or `null`'
optional :selective_sync_shards, type: Array, desc: 'The repository storages whose projects should be synced, if `selective_sync_type` == `shards`'
optional :selective_sync_namespace_ids, as: :namespace_ids, type: Array, desc: 'The IDs of groups that should be synced, if `selective_sync_type` == `namespaces`'
optional :minimum_reverification_interval, type: Integer, desc: 'The interval (in days) in which the repository verification is valid. Once expired, it will be reverified. This has no effect when set on a secondary node.'
end end
post do post do
create_params = declared_params(include_missing: false) create_params = declared_params(include_missing: false)
......
...@@ -32,7 +32,11 @@ describe API::GeoNodes, :geo, :prometheus, api: true do ...@@ -32,7 +32,11 @@ describe API::GeoNodes, :geo, :prometheus, api: true do
it 'delegates the creation of the Geo node to Geo::NodeCreateService' do it 'delegates the creation of the Geo node to Geo::NodeCreateService' do
geo_node_params = { geo_node_params = {
name: 'Test Node 1', name: 'Test Node 1',
url: 'http://example.com' url: 'http://example.com',
selective_sync_type: "shards",
selective_sync_shards: %w[shard1 shard2],
selective_sync_namespace_ids: [group_to_sync.id],
minimum_reverification_interval: 10
} }
expect_any_instance_of(Geo::NodeCreateService).to receive(:execute).once.and_call_original expect_any_instance_of(Geo::NodeCreateService).to receive(:execute).once.and_call_original
post api('/geo_nodes', admin), params: geo_node_params post api('/geo_nodes', admin), params: geo_node_params
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment