mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* [Upgrade Assistant] Fix deprecated index settings resolution (#123599) (#123763)
(cherry picked from commit c5fa8e2be4
)
* fix TS
This commit is contained in:
parent
66cbb5e2e1
commit
c5263b2ece
5 changed files with 88 additions and 24 deletions
|
@ -23,7 +23,7 @@ export const esCriticalAndWarningDeprecations: ESUpgradeStatus = {
|
|||
isCritical: false,
|
||||
type: 'index_settings',
|
||||
resolveDuringUpgrade: false,
|
||||
message: 'translog retention settings are ignored',
|
||||
message: 'Translog retention settings are deprecated',
|
||||
url: 'https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-translog.html',
|
||||
details:
|
||||
'translog retention settings [index.translog.retention.size] and [index.translog.retention.age] are ignored because translog is no longer used in peer recoveries with soft-deletes enabled (default in 7.0 or later)',
|
||||
|
|
|
@ -17,7 +17,7 @@ export const MAJOR_VERSION = '8.0.0';
|
|||
*/
|
||||
export const indexSettingDeprecations = {
|
||||
translog: {
|
||||
deprecationMessage: 'translog retention settings are ignored', // expected message from ES deprecation info API
|
||||
deprecationMessage: 'Translog retention settings are deprecated', // expected message from ES deprecation info API
|
||||
settings: ['translog.retention.size', 'translog.retention.age'],
|
||||
},
|
||||
};
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
"deprecated_settings": [
|
||||
{
|
||||
"level": "warning",
|
||||
"message": "translog retention settings are ignored",
|
||||
"message": "Translog retention settings are deprecated",
|
||||
"url":
|
||||
"https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-translog.html",
|
||||
"details":
|
||||
|
|
|
@ -109,7 +109,7 @@ Object {
|
|||
"details": "translog retention settings [index.translog.retention.size] and [index.translog.retention.age] are ignored because translog is no longer used in peer recoveries with soft-deletes enabled (default in 7.0 or later)",
|
||||
"index": "deprecated_settings",
|
||||
"isCritical": false,
|
||||
"message": "translog retention settings are ignored",
|
||||
"message": "Translog retention settings are deprecated",
|
||||
"resolveDuringUpgrade": false,
|
||||
"type": "index_settings",
|
||||
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-translog.html",
|
||||
|
|
|
@ -5,36 +5,100 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { IndicesCreateRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import expect from '@kbn/expect';
|
||||
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
import {
|
||||
API_BASE_PATH,
|
||||
indexSettingDeprecations,
|
||||
} from '../../../../plugins/upgrade_assistant/common/constants';
|
||||
import { EnrichedDeprecationInfo } from '../../../../plugins/upgrade_assistant/common/types';
|
||||
|
||||
const translogSettingsIndexDeprecation: IndicesCreateRequest = {
|
||||
index: 'deprecated_settings',
|
||||
body: {
|
||||
settings: {
|
||||
'translog.retention.size': '1b',
|
||||
'translog.retention.age': '5m',
|
||||
'index.soft_deletes.enabled': true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
const supertest = getService('supertest');
|
||||
const security = getService('security');
|
||||
const es = getService('es');
|
||||
const log = getService('log');
|
||||
|
||||
describe('Elasticsearch deprecations', () => {
|
||||
describe('GET /api/upgrade_assistant/es_deprecations', () => {
|
||||
it('handles auth error', async () => {
|
||||
const ROLE_NAME = 'authErrorRole';
|
||||
const USER_NAME = 'authErrorUser';
|
||||
const USER_PASSWORD = 'password';
|
||||
describe('error handling', () => {
|
||||
it('handles auth error', async () => {
|
||||
const ROLE_NAME = 'authErrorRole';
|
||||
const USER_NAME = 'authErrorUser';
|
||||
const USER_PASSWORD = 'password';
|
||||
|
||||
try {
|
||||
await security.role.create(ROLE_NAME, {});
|
||||
await security.user.create(USER_NAME, {
|
||||
password: USER_PASSWORD,
|
||||
roles: [ROLE_NAME],
|
||||
});
|
||||
try {
|
||||
await security.role.create(ROLE_NAME, {});
|
||||
await security.user.create(USER_NAME, {
|
||||
password: USER_PASSWORD,
|
||||
roles: [ROLE_NAME],
|
||||
});
|
||||
|
||||
await supertestWithoutAuth
|
||||
.get('/api/upgrade_assistant/es_deprecations')
|
||||
.auth(USER_NAME, USER_PASSWORD)
|
||||
.set('kbn-xsrf', 'kibana')
|
||||
.send()
|
||||
.expect(403);
|
||||
} finally {
|
||||
await security.role.delete(ROLE_NAME);
|
||||
await security.user.delete(USER_NAME);
|
||||
}
|
||||
await supertestWithoutAuth
|
||||
.get(`${API_BASE_PATH}/es_deprecations`)
|
||||
.auth(USER_NAME, USER_PASSWORD)
|
||||
.set('kbn-xsrf', 'kibana')
|
||||
.send()
|
||||
.expect(403);
|
||||
} finally {
|
||||
await security.role.delete(ROLE_NAME);
|
||||
await security.user.delete(USER_NAME);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Only applicable on 7.x
|
||||
describe.skip('index setting deprecation', () => {
|
||||
before(async () => {
|
||||
try {
|
||||
// Create index that will trigger deprecation warning
|
||||
await es.indices.create(translogSettingsIndexDeprecation);
|
||||
} catch (e) {
|
||||
log.debug('Error creating test index');
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
try {
|
||||
await es.indices.delete({
|
||||
index: [translogSettingsIndexDeprecation.index],
|
||||
});
|
||||
} catch (e) {
|
||||
log.debug('Error deleting text index');
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('returns the expected deprecation message for deprecated translog index settings', async () => {
|
||||
const { body: apiRequestResponse } = await supertest
|
||||
.get(`${API_BASE_PATH}/es_deprecations`)
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
.expect(200);
|
||||
|
||||
const indexSettingDeprecation = apiRequestResponse.deprecations.find(
|
||||
(deprecation: EnrichedDeprecationInfo) =>
|
||||
deprecation.index === translogSettingsIndexDeprecation.index
|
||||
);
|
||||
|
||||
expect(indexSettingDeprecation.message).to.equal(
|
||||
indexSettingDeprecations.translog.deprecationMessage
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue