Skip to content

Commit 7846269

Browse files
authored
Merge pull request ceph#62415 from rhcs-dashboard/tenanted-bucket-lifecycle-fix
mgr/dashboard: tenanted bucket lifecycle management fix
2 parents 3689565 + 107abda commit 7846269

File tree

6 files changed

+35
-12
lines changed

6 files changed

+35
-12
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,13 +726,18 @@ def get_encryption_config(self, daemon_name=None, owner=None):
726726
@RESTController.Collection(method='PUT', path='/lifecycle')
727727
@allow_empty_body
728728
def set_lifecycle_policy(self, bucket_name: str = '', lifecycle: str = '', daemon_name=None,
729-
owner=None):
729+
owner=None, tenant=None):
730+
owner = self._get_owner(owner)
731+
bucket_name = RgwBucket.get_s3_bucket_name(bucket_name, tenant)
730732
if lifecycle == '{}':
731733
return self._delete_lifecycle(bucket_name, daemon_name, owner)
732734
return self._set_lifecycle(bucket_name, lifecycle, daemon_name, owner)
733735

734736
@RESTController.Collection(method='GET', path='/lifecycle')
735-
def get_lifecycle_policy(self, bucket_name: str = '', daemon_name=None, owner=None):
737+
def get_lifecycle_policy(self, bucket_name: str = '', daemon_name=None, owner=None,
738+
tenant=None):
739+
owner = self._get_owner(owner)
740+
bucket_name = RgwBucket.get_s3_bucket_name(bucket_name, tenant)
736741
return self._get_lifecycle(bucket_name, daemon_name, owner)
737742

738743
@Endpoint(method='GET', path='/ratelimit')

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-lifecycle-list/rgw-bucket-lifecycle-list.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class RgwBucketLifecycleListComponent implements OnInit {
9595

9696
loadLifecyclePolicies(context: CdTableFetchDataContext) {
9797
const allLifecycleRules$ = this.rgwBucketService
98-
.getLifecycle(this.bucket.bucket, this.bucket.owner)
98+
.getLifecycle(this.bucket.bucket, this.bucket.owner, this.bucket.tenant)
9999
.pipe(
100100
tap((lifecycle: Lifecycle) => {
101101
this.lifecycleRuleList = lifecycle;
@@ -145,7 +145,12 @@ export class RgwBucketLifecycleListComponent implements OnInit {
145145

146146
submitLifecycleConfig(rules: any) {
147147
this.rgwBucketService
148-
.setLifecycle(this.bucket.bucket, JSON.stringify(rules), this.bucket.owner)
148+
.setLifecycle(
149+
this.bucket.bucket,
150+
JSON.stringify(rules),
151+
this.bucket.owner,
152+
this.bucket.tenant
153+
)
149154
.subscribe({
150155
next: () => {
151156
this.notificationService.show(

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-tiering-form/rgw-bucket-tiering-form.component.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe('RgwBucketTieringFormComponent', () => {
6262

6363
it('should call setLifecyclePolicy function', () => {
6464
component.ngOnInit();
65+
component.bucket.tenant = '';
6566
component.tieringForm.setValue({
6667
name: 'test',
6768
storageClass: 'CLOUD',
@@ -80,7 +81,8 @@ describe('RgwBucketTieringFormComponent', () => {
8081
expect(setLifecycleSpy).toHaveBeenCalledWith(
8182
'bucket1',
8283
JSON.stringify(component.configuredLifecycle.LifecycleConfiguration),
83-
'dashboard'
84+
'dashboard',
85+
component.bucket.tenant
8486
);
8587
});
8688
});

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-tiering-form/rgw-bucket-tiering-form.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class RgwBucketTieringFormComponent extends CdForm implements OnInit {
5656

5757
ngOnInit() {
5858
this.rgwBucketService
59-
.getLifecycle(this.bucket.bucket, this.bucket.owner)
59+
.getLifecycle(this.bucket.bucket, this.bucket.owner, this.bucket.tenant)
6060
.subscribe((lifecycle: Lifecycle) => {
6161
if (lifecycle === null) {
6262
lifecycle = { LifecycleConfiguration: { Rule: [] } };
@@ -235,7 +235,8 @@ export class RgwBucketTieringFormComponent extends CdForm implements OnInit {
235235
.setLifecycle(
236236
this.bucket.bucket,
237237
JSON.stringify(this.configuredLifecycle.LifecycleConfiguration),
238-
this.bucket.owner
238+
this.bucket.owner,
239+
this.bucket.tenant
239240
)
240241
.subscribe({
241242
next: () => {
@@ -262,7 +263,8 @@ export class RgwBucketTieringFormComponent extends CdForm implements OnInit {
262263
.setLifecycle(
263264
this.bucket.bucket,
264265
JSON.stringify(this.configuredLifecycle.LifecycleConfiguration),
265-
this.bucket.owner
266+
this.bucket.owner,
267+
this.bucket.tenant
266268
)
267269
.subscribe({
268270
next: () => {

src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,24 @@ export class RgwBucketService extends ApiClient {
250250
});
251251
}
252252

253-
setLifecycle(bucket_name: string, lifecycle: string, owner: string) {
253+
setLifecycle(bucket_name: string, lifecycle: string, owner: string, tenant: string) {
254254
return this.rgwDaemonService.request((params: HttpParams) => {
255255
params = params.appendAll({
256256
bucket_name: bucket_name,
257257
lifecycle: lifecycle,
258-
owner: owner
258+
owner: owner,
259+
tenant: tenant
259260
});
260261
return this.http.put(`${this.url}/lifecycle`, null, { params: params });
261262
});
262263
}
263264

264-
getLifecycle(bucket_name: string, owner: string) {
265+
getLifecycle(bucket_name: string, owner: string, tenant: string) {
265266
return this.rgwDaemonService.request((params: HttpParams) => {
266267
params = params.appendAll({
267268
bucket_name: bucket_name,
268-
owner: owner
269+
owner: owner,
270+
tenant: tenant
269271
});
270272
return this.http.get(`${this.url}/lifecycle`, { params: params });
271273
});

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11607,6 +11607,11 @@ paths:
1160711607
name: owner
1160811608
schema:
1160911609
type: string
11610+
- allowEmptyValue: true
11611+
in: query
11612+
name: tenant
11613+
schema:
11614+
type: string
1161011615
responses:
1161111616
'200':
1161211617
content:
@@ -11643,6 +11648,8 @@ paths:
1164311648
type: string
1164411649
owner:
1164511650
type: string
11651+
tenant:
11652+
type: string
1164611653
type: object
1164711654
responses:
1164811655
'200':

0 commit comments

Comments
 (0)