mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[uiSettings] only try to autoCreateOrUpgrade once (#24605)
## Summary When tests override the `savedObjectsClient.get()` call to always return a 404 an out of memory error is triggered in the tests that's caused because `uiSettings._read()` is constantly trying to recover by running `createOrUpgradeSavedConfig()` and then retrying the `_read()`. Instead we should behave like `_write()` and only try to auto-recover on the first request, then call read with `_read({ ...options, autoCreateOrUpgradeIfMissing: false })` which will prevent the auto-recovery the second time and avoid the OOM. ### Checklist Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR. ~~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~~ ~~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~~ ~~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~~ ~~- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~~ ~~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~~ ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process) - [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)
This commit is contained in:
parent
133be4b16d
commit
52dae6be52
5 changed files with 12 additions and 8 deletions
|
@ -39,7 +39,7 @@ describe('src/dev/build/tasks/nodejs/download_node_builds_task', () => {
|
|||
|
||||
const log = {};
|
||||
const config = {
|
||||
getTargetPlatforms: () => platforms,
|
||||
getNodePlatforms: () => platforms,
|
||||
getNodeVersion: () => 'nodeVersion',
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('src/dev/build/tasks/node_extract_node_builds_task', () => {
|
|||
};
|
||||
|
||||
const config = {
|
||||
getTargetPlatforms: () => [platform]
|
||||
getNodePlatforms: () => [platform]
|
||||
};
|
||||
|
||||
await ExtractNodeBuildsTask.run(config);
|
||||
|
@ -73,7 +73,7 @@ describe('src/dev/build/tasks/node_extract_node_builds_task', () => {
|
|||
};
|
||||
|
||||
const config = {
|
||||
getTargetPlatforms: () => [platform]
|
||||
getNodePlatforms: () => [platform]
|
||||
};
|
||||
|
||||
await ExtractNodeBuildsTask.run(config);
|
||||
|
|
|
@ -39,7 +39,7 @@ describe('src/dev/build/tasks/nodejs/verify_existing_node_builds_task', () => {
|
|||
|
||||
const log = { success: sinon.stub() };
|
||||
const config = {
|
||||
getTargetPlatforms: () => platforms,
|
||||
getNodePlatforms: () => platforms,
|
||||
getNodeVersion: () => 'nodeVersion',
|
||||
};
|
||||
|
||||
|
|
|
@ -525,7 +525,7 @@ describe('ui settings', () => {
|
|||
it('returns the overridden value if the document does not exist', async () => {
|
||||
const overrides = { dateFormat: 'foo' };
|
||||
const { uiSettings, savedObjectsClient } = setup({ overrides });
|
||||
savedObjectsClient.get.throws(savedObjectsClientErrors.createGenericNotFoundError());
|
||||
savedObjectsClient.get.onFirstCall().throws(savedObjectsClientErrors.createGenericNotFoundError());
|
||||
expect(await uiSettings.get('dateFormat')).to.be('foo');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -169,7 +169,8 @@ export class UiSettingsService {
|
|||
|
||||
async _read(options = {}) {
|
||||
const {
|
||||
ignore401Errors = false
|
||||
ignore401Errors = false,
|
||||
autoCreateOrUpgradeIfMissing = true
|
||||
} = options;
|
||||
|
||||
const {
|
||||
|
@ -189,7 +190,7 @@ export class UiSettingsService {
|
|||
const resp = await this._savedObjectsClient.get(this._type, this._id);
|
||||
return resp.attributes;
|
||||
} catch (error) {
|
||||
if (isNotFoundError(error)) {
|
||||
if (isNotFoundError(error) && autoCreateOrUpgradeIfMissing) {
|
||||
const failedUpgradeAttributes = await createOrUpgradeSavedConfig({
|
||||
savedObjectsClient: this._savedObjectsClient,
|
||||
version: this._id,
|
||||
|
@ -205,7 +206,10 @@ export class UiSettingsService {
|
|||
});
|
||||
|
||||
if (!failedUpgradeAttributes) {
|
||||
return await this._read(options);
|
||||
return await this._read({
|
||||
...options,
|
||||
autoCreateOrUpgradeIfMissing: false
|
||||
});
|
||||
}
|
||||
|
||||
return failedUpgradeAttributes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue