mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Only log deprecation warning if xpack:defaultAdminEmail is actually set (#22774)
This PR fixes the logic for logging the deprecation warning introduced with https://github.com/elastic/kibana/pull/22765. Previously Kibana would log the warning if the new `xpack.monitoring.cluster_alerts.email_notifications.email_address` setting was not defined, regardless of `xpack:defaultAdminEmail`'s setting. Now, we will only log the deprecation warning if all of the following are true: 1) `xpack.monitoring.cluster_alerts.email_notifications.email_address` is not set. 2) `xpack:defaultAdminEmail` is set. (**<-- this is the new part**) 3) We haven't already logged the deprecation warning
This commit is contained in:
parent
35226b5948
commit
d021f71f6f
2 changed files with 17 additions and 14 deletions
|
@ -91,10 +91,10 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => {
|
|||
sinon.assert.calledOnce(callCluster);
|
||||
});
|
||||
|
||||
it('logs a deprecation warning', async () => {
|
||||
it('does not log a deprecation warning', async () => {
|
||||
const { config, callCluster, log } = setup({ docExists: false });
|
||||
await getDefaultAdminEmail(config, callCluster, log);
|
||||
sinon.assert.calledOnce(log.warn);
|
||||
sinon.assert.notCalled(log.warn);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -105,10 +105,10 @@ describe('getSettingsCollector / getDefaultAdminEmail', () => {
|
|||
sinon.assert.calledOnce(callCluster);
|
||||
});
|
||||
|
||||
it('logs a deprecation warning', async () => {
|
||||
it('does not log a deprecation warning', async () => {
|
||||
const { config, callCluster, log } = setup({ defaultAdminEmail: false });
|
||||
await getDefaultAdminEmail(config, callCluster, log);
|
||||
sinon.assert.calledOnce(log.warn);
|
||||
sinon.assert.notCalled(log.warn);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -31,15 +31,6 @@ export async function getDefaultAdminEmail(config, callCluster, log) {
|
|||
}
|
||||
|
||||
// DEPRECATED (Remove below in 7.0): If an email address is not configured in kibana.yml, then fallback to xpack:defaultAdminEmail
|
||||
if (!loggedDeprecationWarning) {
|
||||
const message = (
|
||||
`Monitoring is using ${XPACK_DEFAULT_ADMIN_EMAIL_UI_SETTING} for cluster alert notifications, ` +
|
||||
`which will not be supported in Kibana 7.0. Please configure ${emailAddressConfigKey} in your kibana.yml settings`
|
||||
);
|
||||
|
||||
log.warn(message);
|
||||
loggedDeprecationWarning = true;
|
||||
}
|
||||
|
||||
const index = config.get('kibana.index');
|
||||
const version = config.get('pkg.version');
|
||||
|
@ -50,7 +41,19 @@ export async function getDefaultAdminEmail(config, callCluster, log) {
|
|||
ignore: [400, 404] // 400 if the index is closed, 404 if it does not exist
|
||||
});
|
||||
|
||||
return get(uiSettingsDoc, ['_source', 'config', XPACK_DEFAULT_ADMIN_EMAIL_UI_SETTING], null);
|
||||
const emailAddress = get(uiSettingsDoc, ['_source', 'config', XPACK_DEFAULT_ADMIN_EMAIL_UI_SETTING], null);
|
||||
|
||||
if (emailAddress && !loggedDeprecationWarning) {
|
||||
const message = (
|
||||
`Monitoring is using ${XPACK_DEFAULT_ADMIN_EMAIL_UI_SETTING} for cluster alert notifications, ` +
|
||||
`which will not be supported in Kibana 7.0. Please configure ${emailAddressConfigKey} in your kibana.yml settings`
|
||||
);
|
||||
|
||||
log.warn(message);
|
||||
loggedDeprecationWarning = true;
|
||||
}
|
||||
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
// we use shouldUseNull to determine if we need to send nulls; we only send nulls if the last email wasn't null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue