mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-09 01:17:06 +02:00
fix: maintenance mode should assume disable if db call fails. (#6120)
Usually maintenance mode is disabled. If the call throws, which we see a lot of when a unleash instance is in terminating state, we should return a default value. By having it throw inside of the memoizee function, the response is not cached, and it will trigger new calls until it return a cachable result.
This commit is contained in:
parent
c76c8f135a
commit
77b7cb03e9
@ -33,19 +33,22 @@ export default class MaintenanceService implements IMaintenanceStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async isMaintenanceMode(): Promise<boolean> {
|
async isMaintenanceMode(): Promise<boolean> {
|
||||||
return (
|
try {
|
||||||
this.config.flagResolver.isEnabled('maintenanceMode') ||
|
return (
|
||||||
(await this.resolveMaintenance())
|
this.config.flagResolver.isEnabled('maintenanceMode') ||
|
||||||
);
|
(await this.resolveMaintenance())
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.warn('Error checking maintenance mode', e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMaintenanceSetting(): Promise<MaintenanceSchema> {
|
async getMaintenanceSetting(): Promise<MaintenanceSchema> {
|
||||||
this.logger.debug('getMaintenanceSetting called');
|
this.logger.debug('getMaintenanceSetting called');
|
||||||
return (
|
return this.settingService.getWithDefault(maintenanceSettingsKey, {
|
||||||
(await this.settingService.get(maintenanceSettingsKey)) || {
|
enabled: false,
|
||||||
enabled: false,
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async toggleMaintenanceMode(
|
async toggleMaintenanceMode(
|
||||||
|
@ -193,7 +193,7 @@ export default class VersionService {
|
|||||||
)) ?? { id: undefined };
|
)) ?? { id: undefined };
|
||||||
this.instanceId = id;
|
this.instanceId = id;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.warn('Could not find instanceInfo');
|
this.logger.warn('Could not find instanceInfo', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user