summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorafreen23 <afreen23.git@gmail.com>2024-10-10 22:30:24 +0200
committerGitHub <noreply@github.com>2024-10-10 22:30:24 +0200
commita2a4d9b60c9e3bf13646b4d44fe8252f908e168e (patch)
tree5e5cf993db629f35cdc4c0244579fcacaa3699db /src
parentMerge pull request #59045 from pereman2/ignore-pg-degrade-upgrade (diff)
parentmgr/dashboard: unable to edit pipe config for bucket level policy of a bucket (diff)
downloadceph-a2a4d9b60c9e3bf13646b4d44fe8252f908e168e.tar.xz
ceph-a2a4d9b60c9e3bf13646b4d44fe8252f908e168e.zip
Merge pull request #60147 from rhcs-dashboard/sync-policy-pipe-edit-fixes
mgr/dashboard: unable to edit pipe config for bucket level policy of bucket Reviewed-by: Afreen Misbah <afreen23.git@gmail.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/pybind/mgr/dashboard/controllers/rgw.py10
-rw-r--r--src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.html6
-rw-r--r--src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.spec.ts43
-rwxr-xr-xsrc/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.ts7
-rw-r--r--src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-multisite.service.ts11
-rw-r--r--src/pybind/mgr/dashboard/openapi.yaml11
-rwxr-xr-xsrc/pybind/mgr/dashboard/services/rgw_client.py24
7 files changed, 87 insertions, 25 deletions
diff --git a/src/pybind/mgr/dashboard/controllers/rgw.py b/src/pybind/mgr/dashboard/controllers/rgw.py
index 4969d11935d..5b236373cca 100755
--- a/src/pybind/mgr/dashboard/controllers/rgw.py
+++ b/src/pybind/mgr/dashboard/controllers/rgw.py
@@ -244,11 +244,13 @@ class RgwMultisiteController(RESTController):
source_zones: Dict[str, Any],
destination_zones: Dict[str, Any],
source_bucket: str = '',
- destination_bucket: str = '', bucket_name: str = ''):
+ destination_bucket: str = '', bucket_name: str = '',
+ user: str = '', mode: str = ''):
multisite_instance = RgwMultisite()
return multisite_instance.create_sync_pipe(group_id, pipe_id, source_zones,
destination_zones, source_bucket,
- destination_bucket, bucket_name, True)
+ destination_bucket, bucket_name, True,
+ user, mode)
@Endpoint(method='DELETE', path='/sync-pipe')
@EndpointDoc("Remove the sync pipe")
@@ -256,12 +258,10 @@ class RgwMultisiteController(RESTController):
def remove_sync_pipe(self, group_id: str, pipe_id: str,
source_zones: Optional[List[str]] = None,
destination_zones: Optional[List[str]] = None,
- destination_bucket: str = '',
bucket_name: str = ''):
multisite_instance = RgwMultisite()
return multisite_instance.remove_sync_pipe(group_id, pipe_id, source_zones,
- destination_zones, destination_bucket,
- bucket_name, True)
+ destination_zones, bucket_name, True)
@APIRouter('/rgw/daemon', Scope.RGW)
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.html
index e50666cdeaa..767305958d4 100644
--- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.html
+++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.html
@@ -64,6 +64,9 @@
i18n-placeholder
placeholder="Source Bucket Name..."
formControlName="source_bucket"/>
+ <cd-help-text>
+ <span i18n>{{ allBucketSelectedHelpText }}</span>
+ </cd-help-text>
</div>
</div>
<div class="form-group row">
@@ -78,6 +81,9 @@
i18n-placeholder
placeholder="Destination Bucket Name..."
formControlName="destination_bucket"/>
+ <cd-help-text>
+ <span i18n>{{ allBucketSelectedHelpText }}</span>
+ </cd-help-text>
</div>
</div>
</div>
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.spec.ts
index 369658d7d42..1127db1c59a 100644
--- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.spec.ts
+++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.spec.ts
@@ -89,6 +89,47 @@ describe('RgwMultisiteSyncPipeModalComponent', () => {
component.submit();
expect(spy).toHaveBeenCalled();
expect(putDataSpy).toHaveBeenCalled();
- expect(putDataSpy).toHaveBeenCalledWith(component.pipeForm.getRawValue());
+ expect(putDataSpy).toHaveBeenCalledWith({
+ ...component.pipeForm.getRawValue(),
+ mode: '',
+ user: ''
+ });
+ });
+
+ it('should pass "user" and "mode" while creating/editing pipe', () => {
+ component.editing = true;
+ component.pipeForm.patchValue({
+ pipe_id: 'pipe1',
+ group_id: 's3-bucket-replication:enabled',
+ source_bucket: '',
+ source_zones: { added: ['zone1-zg1-realm1'], removed: [] },
+ destination_bucket: '',
+ destination_zones: { added: ['zone2-zg1-realm1'], removed: [] }
+ });
+ component.pipeSelectedRow = {
+ dest: { bucket: '*', zones: ['zone2-zg1-realm1'] },
+ id: 'pipi1',
+ params: {
+ dest: {},
+ mode: 'user',
+ priority: 0,
+ source: { filter: { tags: [] } },
+ user: 'dashboard'
+ },
+ source: { bucket: '*', zones: ['zone1-zg1-realm1'] }
+ };
+
+ component.sourceZones.data.selected = ['zone1-zg1-realm1'];
+ component.destZones.data.selected = ['zone2-zg1-realm1'];
+ const spy = jest.spyOn(component, 'submit');
+ const putDataSpy = jest.spyOn(multisiteServiceMock, 'createEditSyncPipe');
+ component.submit();
+ expect(spy).toHaveBeenCalled();
+ expect(putDataSpy).toHaveBeenCalled();
+ expect(putDataSpy).toHaveBeenCalledWith({
+ ...component.pipeForm.getRawValue(),
+ mode: 'user',
+ user: 'dashboard'
+ });
});
});
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.ts
index 2f41dbd23c8..43742ef60b8 100755
--- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.ts
+++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-sync-pipe-modal/rgw-multisite-sync-pipe-modal.component.ts
@@ -18,6 +18,8 @@ import { ZoneData } from '../models/rgw-multisite-zone-selector';
import { SucceededActionLabelsI18n } from '~/app/shared/constants/app.constants';
const ALL_ZONES = $localize`All zones (*)`;
+const ALL_BUCKET_SELECTED_HELP_TEXT =
+ 'If no value is provided, all the buckets in the zone group will be selected.';
@Component({
selector: 'cd-rgw-multisite-sync-pipe-modal',
@@ -33,6 +35,7 @@ export class RgwMultisiteSyncPipeModalComponent implements OnInit {
sourceZones = new ZoneData(false, 'Filter Zones');
destZones = new ZoneData(false, 'Filter Zones');
icons = Icons;
+ allBucketSelectedHelpText = ALL_BUCKET_SELECTED_HELP_TEXT;
constructor(
public activeModal: NgbActiveModal,
@@ -187,7 +190,9 @@ export class RgwMultisiteSyncPipeModalComponent implements OnInit {
.createEditSyncPipe({
...this.pipeForm.getRawValue(),
source_zones: sourceZones,
- destination_zones: destZones
+ destination_zones: destZones,
+ user: this.editing ? this.pipeSelectedRow?.params?.user : '',
+ mode: this.editing ? this.pipeSelectedRow?.params?.mode : ''
})
.subscribe(
() => {
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-multisite.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-multisite.service.ts
index 690ead734dd..3dc886e172f 100644
--- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-multisite.service.ts
+++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-multisite.service.ts
@@ -129,8 +129,15 @@ export class RgwMultisiteService {
);
}
- createEditSyncPipe(payload: any) {
- return this.http.put(`${this.url}/sync-pipe`, payload);
+ createEditSyncPipe(payload: any, user?: string, mode?: string) {
+ let params = new HttpParams();
+ if (user) {
+ params = params.append('user', user);
+ }
+ if (mode) {
+ params = params.append('mode', mode);
+ }
+ return this.http.put(`${this.url}/sync-pipe`, payload, { params });
}
removeSyncPipe(pipe_id: string, group_id: string, bucket_name?: string) {
diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml
index 1d3f7e3e785..a13ffd9f5af 100644
--- a/src/pybind/mgr/dashboard/openapi.yaml
+++ b/src/pybind/mgr/dashboard/openapi.yaml
@@ -11453,6 +11453,9 @@ paths:
type: string
group_id:
type: string
+ mode:
+ default: ''
+ type: string
pipe_id:
type: string
source_bucket:
@@ -11460,6 +11463,9 @@ paths:
type: string
source_zones:
type: string
+ user:
+ default: ''
+ type: string
required:
- group_id
- pipe_id
@@ -11516,11 +11522,6 @@ paths:
type: string
- default: ''
in: query
- name: destination_bucket
- schema:
- type: string
- - default: ''
- in: query
name: bucket_name
schema:
type: string
diff --git a/src/pybind/mgr/dashboard/services/rgw_client.py b/src/pybind/mgr/dashboard/services/rgw_client.py
index b5c1eca594a..f0352b490f9 100755
--- a/src/pybind/mgr/dashboard/services/rgw_client.py
+++ b/src/pybind/mgr/dashboard/services/rgw_client.py
@@ -2245,7 +2245,8 @@ class RgwMultisite:
source_bucket: str = '',
destination_bucket: str = '',
bucket_name: str = '',
- update_period=False):
+ update_period=False,
+ user: str = '', mode: str = ''):
if source_zones['added'] or destination_zones['added']:
rgw_sync_policy_cmd = ['sync', 'group', 'pipe', 'create',
@@ -2254,11 +2255,9 @@ class RgwMultisite:
if bucket_name:
rgw_sync_policy_cmd += ['--bucket', bucket_name]
- if source_bucket:
- rgw_sync_policy_cmd += ['--source-bucket', source_bucket]
+ rgw_sync_policy_cmd += ['--source-bucket', source_bucket]
- if destination_bucket:
- rgw_sync_policy_cmd += ['--dest-bucket', destination_bucket]
+ rgw_sync_policy_cmd += ['--dest-bucket', destination_bucket]
if source_zones['added']:
rgw_sync_policy_cmd += ['--source-zones', ','.join(source_zones['added'])]
@@ -2266,6 +2265,12 @@ class RgwMultisite:
if destination_zones['added']:
rgw_sync_policy_cmd += ['--dest-zones', ','.join(destination_zones['added'])]
+ if user:
+ rgw_sync_policy_cmd += ['--uid', user]
+
+ if mode:
+ rgw_sync_policy_cmd += ['--mode', mode]
+
logger.info("Creating sync pipe!")
try:
exit_code, _, err = mgr.send_rgwadmin_command(rgw_sync_policy_cmd)
@@ -2280,13 +2285,13 @@ class RgwMultisite:
if ((source_zones['removed'] and '*' not in source_zones['added'])
or (destination_zones['removed'] and '*' not in destination_zones['added'])):
self.remove_sync_pipe(group_id, pipe_id, source_zones['removed'],
- destination_zones['removed'], destination_bucket,
- bucket_name)
+ destination_zones['removed'],
+ bucket_name, True)
def remove_sync_pipe(self, group_id: str, pipe_id: str,
source_zones: Optional[List[str]] = None,
destination_zones: Optional[List[str]] = None,
- destination_bucket: str = '', bucket_name: str = '',
+ bucket_name: str = '',
update_period=False):
rgw_sync_policy_cmd = ['sync', 'group', 'pipe', 'remove',
'--group-id', group_id, '--pipe-id', pipe_id]
@@ -2300,9 +2305,6 @@ class RgwMultisite:
if destination_zones:
rgw_sync_policy_cmd += ['--dest-zones', ','.join(destination_zones)]
- if destination_bucket:
- rgw_sync_policy_cmd += ['--dest-bucket', destination_bucket]
-
logger.info("Removing sync pipe! %s", rgw_sync_policy_cmd)
try:
exit_code, _, err = mgr.send_rgwadmin_command(rgw_sync_policy_cmd)