1
0
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:
Ivar Conradi Østhus 2024-02-03 09:17:11 +01:00 committed by GitHub
parent c76c8f135a
commit 77b7cb03e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 10 deletions

View File

@ -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(

View File

@ -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);
}
}