Skip to content

Commit 4a6d523

Browse files
authored
Merge pull request ceph#59763 from rhcs-dashboard/zonegroup-level-policy-sync
mgr/dashboard: zonegroup level policy created at master zone did not sync to non-master zone Reviewed-by: afreen23 <NOT@FOUND> Reviewed-by: Nizamudeen A <[email protected]>
2 parents 6eb5937 + 52278f1 commit 4a6d523

File tree

4 files changed

+52
-21
lines changed

4 files changed

+52
-21
lines changed

src/pybind/mgr/dashboard/controllers/rgw.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,21 @@ def get_sync_policy_group(self, group_id: str, bucket_name=''):
180180
@CreatePermission
181181
def create_sync_policy_group(self, group_id: str, status: str, bucket_name=''):
182182
multisite_instance = RgwMultisite()
183-
return multisite_instance.create_sync_policy_group(group_id, status, bucket_name)
183+
return multisite_instance.create_sync_policy_group(group_id, status, bucket_name, True)
184184

185185
@Endpoint(method='PUT', path='/sync-policy-group')
186186
@EndpointDoc("Update the sync policy group")
187187
@UpdatePermission
188188
def update_sync_policy_group(self, group_id: str, status: str, bucket_name=''):
189189
multisite_instance = RgwMultisite()
190-
return multisite_instance.update_sync_policy_group(group_id, status, bucket_name)
190+
return multisite_instance.update_sync_policy_group(group_id, status, bucket_name, True)
191191

192192
@Endpoint(method='DELETE', path='/sync-policy-group')
193193
@EndpointDoc("Remove the sync policy group")
194194
@DeletePermission
195195
def remove_sync_policy_group(self, group_id: str, bucket_name=''):
196196
multisite_instance = RgwMultisite()
197-
return multisite_instance.remove_sync_policy_group(group_id, bucket_name)
197+
return multisite_instance.remove_sync_policy_group(group_id, bucket_name, True)
198198

199199
@Endpoint(method='PUT', path='/sync-flow')
200200
@EndpointDoc("Create or update the sync flow")
@@ -206,7 +206,7 @@ def create_sync_flow(self, flow_id: str, flow_type: str, group_id: str,
206206
bucket_name=''):
207207
multisite_instance = RgwMultisite()
208208
return multisite_instance.create_sync_flow(group_id, flow_id, flow_type, zones,
209-
bucket_name, source_zone, destination_zone)
209+
bucket_name, source_zone, destination_zone, True)
210210

211211
@Endpoint(method='DELETE', path='/sync-flow')
212212
@EndpointDoc("Remove the sync flow")
@@ -216,7 +216,7 @@ def remove_sync_flow(self, flow_id: str, flow_type: str, group_id: str,
216216
bucket_name=''):
217217
multisite_instance = RgwMultisite()
218218
return multisite_instance.remove_sync_flow(group_id, flow_id, flow_type, source_zone,
219-
destination_zone, zones, bucket_name)
219+
destination_zone, zones, bucket_name, True)
220220

221221
@Endpoint(method='PUT', path='/sync-pipe')
222222
@EndpointDoc("Create or update the sync pipe")
@@ -229,7 +229,7 @@ def create_sync_pipe(self, group_id: str, pipe_id: str,
229229
multisite_instance = RgwMultisite()
230230
return multisite_instance.create_sync_pipe(group_id, pipe_id, source_zones,
231231
destination_zones, source_bucket,
232-
destination_bucket, bucket_name)
232+
destination_bucket, bucket_name, True)
233233

234234
@Endpoint(method='DELETE', path='/sync-pipe')
235235
@EndpointDoc("Remove the sync pipe")
@@ -242,7 +242,7 @@ def remove_sync_pipe(self, group_id: str, pipe_id: str,
242242
multisite_instance = RgwMultisite()
243243
return multisite_instance.remove_sync_pipe(group_id, pipe_id, source_zones,
244244
destination_zones, destination_bucket,
245-
bucket_name)
245+
bucket_name, True)
246246

247247

248248
@APIRouter('/rgw/daemon', Scope.RGW)

src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.e2e-spec.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
import { BucketsPageHelper } from './buckets.po';
12
import { MultisitePageHelper } from './multisite.po';
23

34
describe('Multisite page', () => {
45
const multisite = new MultisitePageHelper();
6+
const buckets = new BucketsPageHelper();
7+
const bucket_name = 'e2ebucket';
8+
9+
before(() => {
10+
cy.login();
11+
buckets.navigateTo('create');
12+
buckets.create(bucket_name, BucketsPageHelper.USERS[0]);
13+
buckets.getFirstTableCell(bucket_name).should('exist');
14+
});
515

616
beforeEach(() => {
717
cy.login();
@@ -17,13 +27,13 @@ describe('Multisite page', () => {
1727
describe('create, edit & delete sync group policy', () => {
1828
it('should create policy', () => {
1929
multisite.navigateTo('create');
20-
multisite.create('test', 'Enabled');
30+
multisite.create('test', 'Enabled', bucket_name);
2131
multisite.getFirstTableCell('test').should('exist');
2232
});
2333

2434
it('should edit policy status', () => {
2535
multisite.navigateTo();
26-
multisite.edit('test', 'Forbidden');
36+
multisite.edit('test', 'Forbidden', bucket_name);
2737
});
2838

2939
it('should delete policy', () => {
@@ -36,7 +46,7 @@ describe('Multisite page', () => {
3646
describe.skip('create, edit & delete symmetrical sync Flow', () => {
3747
it('Preparing...(creating sync group policy)', () => {
3848
multisite.navigateTo('create');
39-
multisite.create('test', 'Enabled');
49+
multisite.create('test', 'Enabled', bucket_name);
4050
multisite.getFirstTableCell('test').should('exist');
4151
});
4252
describe('symmetrical Flow creation started', () => {

src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/multisite.po.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@ export class MultisitePageHelper extends PageHelper {
2222
}
2323

2424
@PageHelper.restrictTo(pages.create.url)
25-
create(group_id: string, status: string) {
25+
create(group_id: string, status: string, bucket_name: string) {
2626
// Enter in group_id
2727
cy.get('#group_id').type(group_id);
2828
// Show Status
2929
this.selectOption('status', status);
3030
cy.get('#status').should('have.class', 'ng-valid');
31-
31+
// Enter the bucket_name
32+
cy.get('#bucket_name').type(bucket_name);
3233
// Click the create button and wait for policy to be made
3334
cy.contains('button', 'Create Sync Policy Group').wait(WAIT_TIMER).click();
3435
this.getFirstTableCell(group_id).should('exist');
3536
}
3637

3738
@PageHelper.restrictTo(pages.index.url)
38-
edit(group_id: string, status: string) {
39-
cy.visit(`${pages.edit.url}/${group_id})`);
39+
edit(group_id: string, status: string, bucket_name: string) {
40+
cy.visit(`${pages.edit.url}/${group_id}/${bucket_name})`);
4041

4142
// Change the status field
4243
this.selectOption('status', status);

src/pybind/mgr/dashboard/services/rgw_client.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,8 @@ def get_sync_policy_group(self, group_id: str, bucket_name: str = '',
20322032
except SubprocessError as error:
20332033
raise DashboardException(error, http_status_code=500, component='rgw')
20342034

2035-
def create_sync_policy_group(self, group_id: str, status: str, bucket_name: str = ''):
2035+
def create_sync_policy_group(self, group_id: str, status: str, bucket_name: str = '',
2036+
update_period=False):
20362037
rgw_sync_policy_cmd = ['sync', 'group', 'create', '--group-id', group_id,
20372038
'--status', SyncStatus[status].value]
20382039
if bucket_name:
@@ -2044,8 +2045,11 @@ def create_sync_policy_group(self, group_id: str, status: str, bucket_name: str
20442045
http_status_code=500, component='rgw')
20452046
except SubprocessError as error:
20462047
raise DashboardException(error, http_status_code=500, component='rgw')
2048+
if not bucket_name and update_period:
2049+
self.update_period()
20472050

2048-
def update_sync_policy_group(self, group_id: str, status: str, bucket_name: str = ''):
2051+
def update_sync_policy_group(self, group_id: str, status: str, bucket_name: str = '',
2052+
update_period=False):
20492053
rgw_sync_policy_cmd = ['sync', 'group', 'modify', '--group-id', group_id,
20502054
'--status', SyncStatus[status].value]
20512055
if bucket_name:
@@ -2057,8 +2061,10 @@ def update_sync_policy_group(self, group_id: str, status: str, bucket_name: str
20572061
http_status_code=500, component='rgw')
20582062
except SubprocessError as error:
20592063
raise DashboardException(error, http_status_code=500, component='rgw')
2064+
if not bucket_name and update_period:
2065+
self.update_period()
20602066

2061-
def remove_sync_policy_group(self, group_id: str, bucket_name=''):
2067+
def remove_sync_policy_group(self, group_id: str, bucket_name='', update_period=False):
20622068
rgw_sync_policy_cmd = ['sync', 'group', 'remove', '--group-id', group_id]
20632069
if bucket_name:
20642070
rgw_sync_policy_cmd += ['--bucket', bucket_name]
@@ -2069,11 +2075,14 @@ def remove_sync_policy_group(self, group_id: str, bucket_name=''):
20692075
http_status_code=500, component='rgw')
20702076
except SubprocessError as error:
20712077
raise DashboardException(error, http_status_code=500, component='rgw')
2078+
if not bucket_name and update_period:
2079+
self.update_period()
20722080

20732081
def create_sync_flow(self, group_id: str, flow_id: str, flow_type: str,
20742082
zones: Optional[Dict[str, List]] = None, bucket_name: str = '',
20752083
source_zone: Optional[str] = None,
2076-
destination_zone: Optional[str] = None):
2084+
destination_zone: Optional[str] = None,
2085+
update_period=False):
20772086
rgw_sync_policy_cmd = ['sync', 'group', 'flow', 'create', '--group-id', group_id,
20782087
'--flow-id', flow_id, '--flow-type', SyncFlowTypes[flow_type].value]
20792088

@@ -2114,10 +2123,13 @@ def create_sync_flow(self, group_id: str, flow_id: str, flow_type: str,
21142123
if len(zones['removed']) > 0:
21152124
self.remove_sync_flow(group_id, flow_id, flow_type, source_zone,
21162125
destination_zone, zones['removed'], bucket_name)
2126+
if not bucket_name and update_period:
2127+
self.update_period()
21172128

21182129
def remove_sync_flow(self, group_id: str, flow_id: str, flow_type: str,
21192130
source_zone='', destination_zone='',
2120-
zones: Optional[List[str]] = None, bucket_name: str = ''):
2131+
zones: Optional[List[str]] = None, bucket_name: str = '',
2132+
update_period=False):
21212133
rgw_sync_policy_cmd = ['sync', 'group', 'flow', 'remove', '--group-id', group_id,
21222134
'--flow-id', flow_id, '--flow-type', SyncFlowTypes[flow_type].value]
21232135

@@ -2138,13 +2150,16 @@ def remove_sync_flow(self, group_id: str, flow_id: str, flow_type: str,
21382150
http_status_code=500, component='rgw')
21392151
except SubprocessError as error:
21402152
raise DashboardException(error, http_status_code=500, component='rgw')
2153+
if not bucket_name and update_period:
2154+
self.update_period()
21412155

21422156
def create_sync_pipe(self, group_id: str, pipe_id: str,
21432157
source_zones: Dict[str, Any],
21442158
destination_zones: Dict[str, Any],
21452159
source_bucket: str = '',
21462160
destination_bucket: str = '',
2147-
bucket_name: str = ''):
2161+
bucket_name: str = '',
2162+
update_period=False):
21482163

21492164
if source_zones['added'] or destination_zones['added']:
21502165
rgw_sync_policy_cmd = ['sync', 'group', 'pipe', 'create',
@@ -2173,6 +2188,8 @@ def create_sync_pipe(self, group_id: str, pipe_id: str,
21732188
http_status_code=500, component='rgw')
21742189
except SubprocessError as error:
21752190
raise DashboardException(error, http_status_code=500, component='rgw')
2191+
if not bucket_name and update_period:
2192+
self.update_period()
21762193

21772194
if source_zones['removed'] or destination_zones['removed']:
21782195
self.remove_sync_pipe(group_id, pipe_id, source_zones['removed'],
@@ -2182,7 +2199,8 @@ def create_sync_pipe(self, group_id: str, pipe_id: str,
21822199
def remove_sync_pipe(self, group_id: str, pipe_id: str,
21832200
source_zones: Optional[List[str]] = None,
21842201
destination_zones: Optional[List[str]] = None,
2185-
destination_bucket: str = '', bucket_name: str = ''):
2202+
destination_bucket: str = '', bucket_name: str = '',
2203+
update_period=False):
21862204
rgw_sync_policy_cmd = ['sync', 'group', 'pipe', 'remove',
21872205
'--group-id', group_id, '--pipe-id', pipe_id]
21882206

@@ -2206,6 +2224,8 @@ def remove_sync_pipe(self, group_id: str, pipe_id: str,
22062224
http_status_code=500, component='rgw')
22072225
except SubprocessError as error:
22082226
raise DashboardException(error, http_status_code=500, component='rgw')
2227+
if not bucket_name and update_period:
2228+
self.update_period()
22092229

22102230
def create_dashboard_admin_sync_group(self, zonegroup_name: str = ''):
22112231

0 commit comments

Comments
 (0)