From 78715e33747acca1958b1cbb130932c7f22c5197 Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Thu, 25 May 2023 08:28:05 +0200 Subject: [PATCH] docs: maintanance mode impact (#3858) --- src/lib/services/maintenance-service.test.ts | 44 ++++++++++++++++++++ website/docs/reference/maintenance-mode.mdx | 15 +++++++ 2 files changed, 59 insertions(+) create mode 100644 src/lib/services/maintenance-service.test.ts diff --git a/src/lib/services/maintenance-service.test.ts b/src/lib/services/maintenance-service.test.ts new file mode 100644 index 0000000000..bcc7dd32d8 --- /dev/null +++ b/src/lib/services/maintenance-service.test.ts @@ -0,0 +1,44 @@ +import { SchedulerService } from './scheduler-service'; +import MaintenanceService from './maintenance-service'; +import { IUnleashStores } from '../types'; +import SettingService from './setting-service'; +import { createTestConfig } from '../../test/config/test-config'; + +test('Maintenance on should pause scheduler', async () => { + const config = createTestConfig(); + const schedulerService = new SchedulerService(config.getLogger); + const maintenanceService = new MaintenanceService( + {} as IUnleashStores, + config, + { insert() {} } as unknown as SettingService, + schedulerService, + ); + + await maintenanceService.toggleMaintenanceMode( + { enabled: true }, + 'irrelevant user', + ); + + expect(schedulerService.getMode()).toBe('paused'); + schedulerService.stop(); +}); + +test('Maintenance off should resume scheduler', async () => { + const config = createTestConfig(); + const schedulerService = new SchedulerService(config.getLogger); + schedulerService.pause(); + const maintenanceService = new MaintenanceService( + {} as IUnleashStores, + config, + { insert() {} } as unknown as SettingService, + schedulerService, + ); + + await maintenanceService.toggleMaintenanceMode( + { enabled: false }, + 'irrelevant user', + ); + + expect(schedulerService.getMode()).toBe('active'); + schedulerService.stop(); +}); diff --git a/website/docs/reference/maintenance-mode.mdx b/website/docs/reference/maintenance-mode.mdx index b1cfe79165..d00bc50eb4 100644 --- a/website/docs/reference/maintenance-mode.mdx +++ b/website/docs/reference/maintenance-mode.mdx @@ -25,3 +25,18 @@ Maintenance mode is controlled from the "maintenance" section of the Unleash adm When maintenance mode is enabled, a warning banner appears at the top of the Unleash dashboard, indicating that any changes made during this period will not be saved and may result in errors. ![Maintenance mode banner when maintenance mod is toggled on](/img/maintenance-banner.png) + +## Maintenance mode and scheduled jobs + +When maintenance mode is enabled all internal jobs performed by Unleash such as updating metrics and statistics are paused. When maintenance mode is toggled back to disabled later, all scheduled +jobs are resumed. + +## Maintenance mode and read-only DB user + +When maintenance mode is enabled most DB operations are suspended so you can use even read-only DB user. There's one exception though. +Unleash DB user role needs a DELETE and UPDATE permission on the unleash_session table. + +``` +GRANT DELETE ON unleash_session TO my_db_role; +GRANT UPDATE ON unleash_session TO my_db_role; +```