Inventory(Buckets and users) data is wrong when you have buckets across multiple daemons.
Fixes: https://tracker.ceph.com/issues/62565
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
return CephService.get_encryption_config(daemon_name)
+@UIRouter('/rgw/bucket', Scope.RGW)
+class RgwBucketUi(RgwBucket):
+ @Endpoint('GET')
+ @ReadPermission
+ # pylint: disable=W0613
+ def buckets_and_users_count(self, daemon_name=None):
+ buckets_count = 0
+ users_count = 0
+ daemon_object = RgwDaemon()
+ daemons = json.loads(daemon_object.list())
+ for daemon in daemons:
+ buckets = json.loads(RgwBucket.list(self, daemon_name=daemon['id']))
+ users = json.loads(RgwUser.list(self, daemon_name=daemon['id']))
+ users_count += len(users)
+ buckets_count += len(buckets)
+ return {
+ 'buckets_count': buckets_count,
+ 'users_count': users_count
+ }
+
+
@APIRouter('/rgw/user', Scope.RGW)
@APIDoc("RGW User Management API", "RgwUser")
class RgwUser(RgwRESTController):
import { RgwZonegroupService } from '~/app/shared/api/rgw-zonegroup.service';
import { RgwZoneService } from '~/app/shared/api/rgw-zone.service';
import { RgwBucketService } from '~/app/shared/api/rgw-bucket.service';
-import { RgwUserService } from '~/app/shared/api/rgw-user.service';
import { HealthService } from '~/app/shared/api/health.service';
import { CardRowComponent } from '~/app/shared/components/card-row/card-row.component';
import { CardComponent } from '~/app/shared/components/card/card.component';
zones: ['zone4', 'zone5', 'zone6', 'zone7']
};
- const bucketList = [
- {
- bucket: 'bucket',
- owner: 'testid',
- usage: {
- 'rgw.main': {
- size_actual: 4,
- num_objects: 2
- },
- 'rgw.none': {
- size_actual: 6,
- num_objects: 6
- }
- },
- bucket_quota: {
- max_size: 20,
- max_objects: 10,
- enabled: true
- }
- },
- {
- bucket: 'bucket2',
- owner: 'testid',
- usage: {
- 'rgw.main': {
- size_actual: 4,
- num_objects: 2
- },
- 'rgw.none': {
- size_actual: 6,
- num_objects: 6
- }
- },
- bucket_quota: {
- max_size: 20,
- max_objects: 10,
- enabled: true
- }
- }
- ];
-
- const userList = [
- {
- user_id: 'testid',
- stats: {
- size_actual: 6,
- num_objects: 6
- },
- user_quota: {
- max_size: 20,
- max_objects: 10,
- enabled: true
- }
- },
- {
- user_id: 'testid2',
- stats: {
- size_actual: 6,
- num_objects: 6
- },
- user_quota: {
- max_size: 20,
- max_objects: 10,
- enabled: true
- }
- }
- ];
+ const bucketAndUserList = {
+ buckets_count: 2,
+ users_count: 2
+ };
const healthData = {
total_objects: '290',
let listZonegroupsSpy: jest.SpyInstance;
let listRealmsSpy: jest.SpyInstance;
let listBucketsSpy: jest.SpyInstance;
- let listUsersSpy: jest.SpyInstance;
let healthDataSpy: jest.SpyInstance;
beforeEach(async () => {
.mockReturnValue(of(zonegroupList));
listZonesSpy = jest.spyOn(TestBed.inject(RgwZoneService), 'list').mockReturnValue(of(zoneList));
listBucketsSpy = jest
- .spyOn(TestBed.inject(RgwBucketService), 'list')
- .mockReturnValue(of(bucketList));
- listUsersSpy = jest.spyOn(TestBed.inject(RgwUserService), 'list').mockReturnValue(of(userList));
+ .spyOn(TestBed.inject(RgwBucketService), 'getTotalBucketsAndUsersLength')
+ .mockReturnValue(of(bucketAndUserList));
healthDataSpy = jest
.spyOn(TestBed.inject(HealthService), 'getClusterCapacity')
.mockReturnValue(of(healthData));
it('should get corresponding data into Buckets', () => {
expect(listBucketsSpy).toHaveBeenCalled();
expect(component.rgwBucketCount).toEqual(2);
- });
-
- it('should get corresponding data into Users', () => {
- expect(listUsersSpy).toHaveBeenCalled();
expect(component.UserCount).toEqual(2);
});
import { RgwZoneService } from '~/app/shared/api/rgw-zone.service';
import { RgwZonegroupService } from '~/app/shared/api/rgw-zonegroup.service';
import { RgwBucketService } from '~/app/shared/api/rgw-bucket.service';
-import { RgwUserService } from '~/app/shared/api/rgw-user.service';
import { PrometheusService } from '~/app/shared/api/prometheus.service';
import { RgwPromqls as queries } from '~/app/shared/enum/dashboard-promqls.enum';
multisiteInfo: object[] = [];
ZonegroupSub: Subscription;
ZoneSUb: Subscription;
- UserSub: Subscription;
HealthSub: Subscription;
BucketSub: Subscription;
queriesResults: any = {
private rgwZonegroupService: RgwZonegroupService,
private rgwZoneService: RgwZoneService,
private rgwBucketService: RgwBucketService,
- private rgwUserService: RgwUserService,
private prometheusService: PrometheusService,
private rgwMultisiteService: RgwMultisiteService
) {
this.daemonSub = this.rgwDaemonService.list().subscribe((data: any) => {
this.rgwDaemonCount = data.length;
});
- this.BucketSub = this.rgwBucketService.list().subscribe((data: any) => {
- this.rgwBucketCount = data.length;
- });
- this.UserSub = this.rgwUserService.list().subscribe((data: any) => {
- this.UserCount = data.length;
- });
this.HealthSub = this.healthService.getClusterCapacity().subscribe((data: any) => {
this.objectCount = data['total_objects'];
this.totalPoolUsedBytes = data['total_pool_bytes_used'];
});
this.getSyncStatus();
});
+ this.BucketSub = this.rgwBucketService
+ .getTotalBucketsAndUsersLength()
+ .subscribe((data: any) => {
+ this.rgwBucketCount = data['buckets_count'];
+ this.UserCount = data['users_count'];
+ });
this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
this.rgwRealmCount = data['realms'].length;
});
this.ZonegroupSub.unsubscribe();
this.ZoneSUb.unsubscribe();
this.BucketSub.unsubscribe();
- this.UserSub.unsubscribe();
this.HealthSub.unsubscribe();
if (this.timerGetPrometheusDataSub) {
this.timerGetPrometheusDataSub.unsubscribe();
});
}
+ getTotalBucketsAndUsersLength() {
+ return this.rgwDaemonService.request((params: HttpParams) => {
+ return this.http.get(`ui-${this.url}/buckets_and_users_count`, { params: params });
+ });
+ }
+
create(
bucket: string,
uid: string,