mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01: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> {
|
||||
return (
|
||||
this.config.flagResolver.isEnabled('maintenanceMode') ||
|
||||
(await this.resolveMaintenance())
|
||||
);
|
||||
try {
|
||||
return (
|
||||
this.config.flagResolver.isEnabled('maintenanceMode') ||
|
||||
(await this.resolveMaintenance())
|
||||
);
|
||||
} catch (e) {
|
||||
this.logger.warn('Error checking maintenance mode', e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async getMaintenanceSetting(): Promise<MaintenanceSchema> {
|
||||
this.logger.debug('getMaintenanceSetting called');
|
||||
return (
|
||||
(await this.settingService.get(maintenanceSettingsKey)) || {
|
||||
enabled: false,
|
||||
}
|
||||
);
|
||||
return this.settingService.getWithDefault(maintenanceSettingsKey, {
|
||||
enabled: false,
|
||||
});
|
||||
}
|
||||
|
||||
async toggleMaintenanceMode(
|
||||
|
@ -193,7 +193,7 @@ export default class VersionService {
|
||||
)) ?? { id: undefined };
|
||||
this.instanceId = id;
|
||||
} 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