Skip to content

Commit

Permalink
Deprecate reporting.index setting (#84005)
Browse files Browse the repository at this point in the history
* Deprecating `xpack.reporting.index` setting

* Adding unit test

* Now with more standard deprecation messages

* Updating the xpack.reporting.index docs

* Fixing tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
kobelb and kibanamachine authored Dec 3, 2020
1 parent 145c0a5 commit f9ade90
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/settings/reporting-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ For information about {kib} memory limits, see <<production, using {kib} in a pr
[cols="2*<"]
|===
| `xpack.reporting.index`
| Reporting uses a weekly index in {es} to store the reporting job and
| *deprecated* This setting is deprecated and will be removed in 8.0. Multitenancy by changing
`kibana.index` will not be supported starting in 8.0. See https://ela.st/kbn-remove-legacy-multitenancy[8.0 Breaking Changes]
for more details. Reporting uses a weekly index in {es} to store the reporting job and
the report content. The index is automatically created if it does not already
exist. Configure this to a unique value, beginning with `.reporting-`, for every
{kib} instance that has a unique <<kibana-index, `kibana.index`>> setting. Defaults to `.reporting`.
Expand Down
42 changes: 42 additions & 0 deletions x-pack/plugins/reporting/server/config/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { config } from './index';
import { applyDeprecations, configDeprecationFactory } from '@kbn/config';

const CONFIG_PATH = 'xpack.reporting';

const applyReportingDeprecations = (settings: Record<string, any> = {}) => {
const deprecations = config.deprecations!(configDeprecationFactory);
const deprecationMessages: string[] = [];
const _config: any = {};
_config[CONFIG_PATH] = settings;
const migrated = applyDeprecations(
_config,
deprecations.map((deprecation) => ({
deprecation,
path: CONFIG_PATH,
})),
(msg) => deprecationMessages.push(msg)
);
return {
messages: deprecationMessages,
migrated,
};
};

describe('deprecations', () => {
['.foo', '.reporting'].forEach((index) => {
it('logs a warning if index is set', () => {
const { messages } = applyReportingDeprecations({ index });
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"xpack.reporting.index\\" is deprecated. Multitenancy by changing \\"kibana.index\\" will not be supported starting in 8.0. See https://ela.st/kbn-remove-legacy-multitenancy for more details",
]
`);
});
});
});
10 changes: 10 additions & 0 deletions x-pack/plugins/reporting/server/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { get } from 'lodash';
import { PluginConfigDescriptor } from 'kibana/server';
import { ConfigSchema, ReportingConfigType } from './schema';
export { buildConfig } from './config';
Expand All @@ -20,5 +21,14 @@ export const config: PluginConfigDescriptor<ReportingConfigType> = {
unused('poll.jobCompletionNotifier.intervalErrorMultiplier'),
unused('poll.jobsRefresh.intervalErrorMultiplier'),
unused('kibanaApp'),
(settings, fromPath, log) => {
const reporting = get(settings, fromPath);
if (reporting?.index) {
log(
`"${fromPath}.index" is deprecated. Multitenancy by changing "kibana.index" will not be supported starting in 8.0. See https://ela.st/kbn-remove-legacy-multitenancy for more details`
);
}
return settings;
},
],
};

0 comments on commit f9ade90

Please sign in to comment.