From 499d289ba5297bae39e84dae2fc30726db26b110 Mon Sep 17 00:00:00 2001 From: Ivo Almeida Date: Sun, 10 Dec 2023 17:44:33 +0000 Subject: [PATCH] mgr/dashboard: snap schedule module detect/eneable Fixes: https://tracker.ceph.com/issues/63768 Signed-off-by: Ivo Almeida --- ...ephfs-snapshotschedule-list.component.html | 74 +++++++----- .../cephfs-snapshotschedule-list.component.ts | 107 ++++++++++++++++-- .../rgw-multisite-details.component.html | 8 +- 3 files changed, 149 insertions(+), 40 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-snapshotschedule-list/cephfs-snapshotschedule-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-snapshotschedule-list/cephfs-snapshotschedule-list.component.html index 2e270057d579f..0346de67f9419 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-snapshotschedule-list/cephfs-snapshotschedule-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-snapshotschedule-list/cephfs-snapshotschedule-list.component.html @@ -1,44 +1,66 @@ - - - Loading snapshot schedules... - - + + In order to access the snapshot scheduler feature, the snap_scheduler module must be enabled + + - + {{row.path | path}} + triggers="click:blur"> + {{ row.path | path }} + - - + + - + - {{ row.path }} - - - - - + {{ row.path }} + + + + ; subject$ = new BehaviorSubject([]); - isLoading$ = new BehaviorSubject(true); + snapScheduleModuleStatus$ = new BehaviorSubject(false); + moduleServiceListSub!: Subscription; columns: CdTableColumn[] = []; tableActions: CdTableAction[] = []; context!: CdTableFetchDataContext; @@ -39,10 +57,15 @@ export class CephfsSnapshotscheduleListComponent extends CdForm implements OnIni selectedName: string = ''; icons = Icons; + MODULE_NAME = 'snap_schedule'; + ENABLE_MODULE_TIMER = 2 * 1000; + constructor( private snapshotScheduleService: CephfsSnapshotScheduleService, private authStorageService: AuthStorageService, - private modalService: ModalService + private modalService: ModalService, + private mgrModuleService: MgrModuleService, + private notificationService: NotificationService ) { super(); this.permissions = this.authStorageService.getPermissions(); @@ -55,13 +78,27 @@ export class CephfsSnapshotscheduleListComponent extends CdForm implements OnIni } ngOnInit(): void { + this.moduleServiceListSub = this.mgrModuleService + .list() + .pipe( + map((modules: any[]) => modules.find((module) => module?.['name'] === this.MODULE_NAME)) + ) + .subscribe({ + next: (module: any) => this.snapScheduleModuleStatus$.next(module?.enabled) + }); + this.snapshotSchedules$ = this.subject$.pipe( switchMap(() => - this.snapshotScheduleService - .getSnapshotScheduleList('/', this.fsName) - .pipe(finalize(() => this.isLoading$.next(false))) - ), - shareReplay(1) + this.snapScheduleModuleStatus$.pipe( + switchMap((status) => { + if (!status) { + return of([]); + } + return this.snapshotScheduleService.getSnapshotScheduleList('/', this.fsName); + }), + shareReplay(1) + ) + ) ); this.columns = [ @@ -78,6 +115,10 @@ export class CephfsSnapshotscheduleListComponent extends CdForm implements OnIni this.tableActions = []; } + ngOnDestroy(): void { + this.moduleServiceListSub.unsubscribe(); + } + fetchData() { this.subject$.next([]); } @@ -96,4 +137,48 @@ export class CephfsSnapshotscheduleListComponent extends CdForm implements OnIni { size: 'lg' } ); } + + enableSnapshotSchedule() { + let $obs; + const fnWaitUntilReconnected = () => { + timer(this.ENABLE_MODULE_TIMER).subscribe(() => { + // Trigger an API request to check if the connection is + // re-established. + this.mgrModuleService.list().subscribe( + () => { + // Resume showing the notification toasties. + this.notificationService.suspendToasties(false); + // Unblock the whole UI. + this.blockUI.stop(); + // Reload the data table content. + this.notificationService.show( + NotificationType.success, + $localize`Enabled Snapshot Schedule Module` + ); + // Reload the data table content. + }, + () => { + fnWaitUntilReconnected(); + } + ); + }); + }; + + if (!this.snapScheduleModuleStatus$.value) { + $obs = this.mgrModuleService + .enable(this.MODULE_NAME) + .pipe(finalize(() => this.snapScheduleModuleStatus$.next(true))); + } + $obs.subscribe( + () => undefined, + () => { + // Suspend showing the notification toasties. + this.notificationService.suspendToasties(true); + // Block the whole UI to prevent user interactions until + // the connection to the backend is reestablished + this.blockUI.start($localize`Reconnecting, please wait ...`); + fnWaitUntilReconnected(); + } + ); + } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html index 5274cf73a5569..291013a5ce2f1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html @@ -4,10 +4,12 @@ In order to access the import/export feature, the rgw module must be enabled - - Enable the Object Gateway Module + +