mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Fix plugin deprecations (#29737)
* [deprecations] convert flattened settings to nested settings * [deprecations] reuse rename method for elasticsearch.url to elasticsearch.hosts * newline * add known issues to docs
This commit is contained in:
parent
6b3170a8e7
commit
a0b806cd6d
5 changed files with 52 additions and 38 deletions
|
@ -87,6 +87,13 @@ This section summarizes the changes in each release.
|
|||
[[release-notes-6.6.0]]
|
||||
== {kib} 6.6.0
|
||||
|
||||
[float]
|
||||
[[known-issues-6.6.0]]
|
||||
=== Known issues
|
||||
|
||||
* {kib} may not start when using deprecated plugin settings in kibana.yml
|
||||
+
|
||||
The server will log an error and the new configuration value. Updating kibana.yml with the new configuration will allow the server to start.
|
||||
|
||||
[float]
|
||||
[[breaking-6.6.0]]
|
||||
|
|
|
@ -106,27 +106,10 @@ export default function (kibana) {
|
|||
};
|
||||
};
|
||||
|
||||
const url = () => {
|
||||
return (settings, log) => {
|
||||
const deprecatedUrl = get(settings, 'url');
|
||||
const hosts = get(settings, 'hosts.length');
|
||||
if (!deprecatedUrl) {
|
||||
return;
|
||||
}
|
||||
if (hosts) {
|
||||
log('Deprecated config key "elasticsearch.url" conflicts with "elasticsearch.hosts". Ignoring "elasticsearch.url"');
|
||||
} else {
|
||||
set(settings, 'hosts', [deprecatedUrl]);
|
||||
log('Config key "elasticsearch.url" is deprecated. It has been replaced with "elasticsearch.hosts"');
|
||||
}
|
||||
unset(settings, 'url');
|
||||
};
|
||||
};
|
||||
|
||||
return [
|
||||
rename('ssl.ca', 'ssl.certificateAuthorities'),
|
||||
rename('ssl.cert', 'ssl.certificate'),
|
||||
url(),
|
||||
rename('url', 'hosts'),
|
||||
sslVerify(),
|
||||
rename('tribe.ssl.ca', 'tribe.ssl.certificateAuthorities'),
|
||||
rename('tribe.ssl.cert', 'tribe.ssl.certificate'),
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { difference } from 'lodash';
|
||||
import { difference, get, set } from 'lodash';
|
||||
import { transformDeprecations } from './transform_deprecations';
|
||||
import { unset, formatListAsProse, getFlattenedObject } from '../../utils';
|
||||
import { getTransform } from '../../deprecation';
|
||||
|
@ -39,9 +39,13 @@ async function getUnusedConfigKeys(
|
|||
const { spec } = plugins[i];
|
||||
const transform = await getTransform(spec);
|
||||
const prefix = spec.getConfigPrefix();
|
||||
const pluginSettings = settings[prefix];
|
||||
|
||||
// nested plugin prefixes (a.b) translate to nested objects
|
||||
const pluginSettings = get(settings, prefix);
|
||||
if (pluginSettings) {
|
||||
settings[prefix] = transform(pluginSettings);
|
||||
// flattened settings are expected to be converted to nested objects
|
||||
// a.b = true => { a: { b: true }}
|
||||
set(settings, prefix, transform(pluginSettings));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -252,6 +252,41 @@ describe('server/config completeMixin()', function () {
|
|||
|
||||
await expect(callCompleteMixin()).resolves.toBe(undefined);
|
||||
});
|
||||
|
||||
it('should transform deeply nested deprecated plugin settings', async () => {
|
||||
const { callCompleteMixin } = setup({
|
||||
settings: {
|
||||
xpack: {
|
||||
monitoring: {
|
||||
elasticsearch: {
|
||||
url: 'http://localhost:9200'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
configValues: {
|
||||
xpack: {
|
||||
monitoring: {
|
||||
elasticsearch: {
|
||||
hosts: 'http://localhost:9200'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
spec: {
|
||||
getDeprecationsProvider() {
|
||||
return async ({ rename }) => [rename('elasticsearch.url', 'elasticsearch.hosts')];
|
||||
},
|
||||
getConfigPrefix: () => 'xpack.monitoring'
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
await expect(callCompleteMixin()).resolves.toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('disabled plugins', () => {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { get, has, set, unset } from 'lodash';
|
||||
import { get, has, set } from 'lodash';
|
||||
import { CLUSTER_ALERTS_ADDRESS_CONFIG_KEY } from './common/constants';
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,7 @@ export const deprecations = ({ rename }) => {
|
|||
return [
|
||||
rename('elasticsearch.ssl.ca', 'elasticsearch.ssl.certificateAuthorities'),
|
||||
rename('elasticsearch.ssl.cert', 'elasticsearch.ssl.certificate'),
|
||||
rename('elasticsearch.url', 'elasticsearch.hosts'),
|
||||
(settings, log) => {
|
||||
if (!has(settings, 'elasticsearch.ssl.verify')) {
|
||||
return;
|
||||
|
@ -50,22 +51,6 @@ export const deprecations = ({ rename }) => {
|
|||
if (emailNotificationsEnabled && !get(settings, CLUSTER_ALERTS_ADDRESS_CONFIG_KEY)) {
|
||||
log(`Config key "${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}" will be required for email notifications to work in 7.0."`);
|
||||
}
|
||||
},
|
||||
(settings, log) => {
|
||||
const deprecatedUrl = get(settings, 'url');
|
||||
const hosts = get(settings, 'hosts.length');
|
||||
if (!deprecatedUrl) {
|
||||
return;
|
||||
}
|
||||
if (hosts) {
|
||||
log('Deprecated config key "xpack.monitoring.elasticsearch.url" ' +
|
||||
'conflicts with "xpack.monitoring.elasticsearch.hosts". Ignoring "elasticsearch.url"');
|
||||
} else {
|
||||
set(settings, 'hosts', [deprecatedUrl]);
|
||||
log('Config key "xpack.monitoring.elasticsearch.url" is deprecated.' +
|
||||
'It has been replaced with "xpack.monitoring.elasticsearch.hosts"');
|
||||
}
|
||||
unset(settings, 'url');
|
||||
}
|
||||
];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue