[Rollups] Disable Rollups index data enricher if Rollups UI is disabled (#167295)

## Summary

Fixes https://github.com/elastic/kibana/issues/167231 

This PR introduces following changes, if the config
`xpack.rollup.ui.enabled` is set to `false`:
- on the client side:
  - don't add the Rollup toggle to Index Management
  - don't add the Rollup badge to Index Management
- on the server side: 
  - don't add Rollup data enricher to Index Management
- don't enable Rollup in data views and data search (the same is done on
the client side already)
This commit is contained in:
Yulia Čech 2023-10-04 16:52:04 +02:00 committed by GitHub
parent 8a2843e281
commit 79411d97c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 122 additions and 25 deletions

View file

@ -186,6 +186,7 @@ enabled:
- x-pack/test/api_integration/apis/logs_ui/config.ts
- x-pack/test/api_integration/apis/logstash/config.ts
- x-pack/test/api_integration/apis/management/config.ts
- x-pack/test/api_integration/apis/management/index_management/disabled_data_enrichers/config.ts
- x-pack/test/api_integration/apis/maps/config.ts
- x-pack/test/api_integration/apis/metrics_ui/config.ts
- x-pack/test/api_integration/apis/ml/config.ts

View file

@ -14,7 +14,6 @@ import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { DataViewsPublicPluginSetup } from '@kbn/data-views-plugin/public/types';
import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_management';
import { UIM_APP_NAME } from '../common';
// @ts-ignore
import { setHttp, init as initDocumentation } from './crud_app/services';
import { setNotifications, setFatalErrors, setUiStatsReporter } from './kibana_services';
import { ClientConfigType } from './types';
@ -43,27 +42,27 @@ export class RollupPlugin implements Plugin {
setUiStatsReporter(usageCollection.reportUiCounter.bind(usageCollection, UIM_APP_NAME));
}
if (indexManagement) {
indexManagement.extensionsService.addBadge(rollupBadgeExtension);
indexManagement.extensionsService.addToggle(rollupToggleExtension);
}
if (home && isRollupUiEnabled) {
home.featureCatalogue.register({
id: 'rollup_jobs',
title: 'Rollups',
description: i18n.translate('xpack.rollupJobs.featureCatalogueDescription', {
defaultMessage:
'Summarize and store historical data in a smaller index for future analysis.',
}),
icon: 'indexRollupApp',
path: `/app/management/data/rollup_jobs/job_list`,
showOnHomePage: false,
category: 'admin',
});
}
if (isRollupUiEnabled) {
if (indexManagement) {
indexManagement.extensionsService.addBadge(rollupBadgeExtension);
indexManagement.extensionsService.addToggle(rollupToggleExtension);
}
if (home) {
home.featureCatalogue.register({
id: 'rollup_jobs',
title: 'Rollups',
description: i18n.translate('xpack.rollupJobs.featureCatalogueDescription', {
defaultMessage:
'Summarize and store historical data in a smaller index for future analysis.',
}),
icon: 'indexRollupApp',
path: `/app/management/data/rollup_jobs/job_list`,
showOnHomePage: false,
category: 'admin',
});
}
dataViews.enableRollups();
const pluginName = i18n.translate('xpack.rollupJobs.appTitle', {
defaultMessage: 'Rollup Jobs',

View file

@ -19,12 +19,15 @@ import { rollupDataEnricher } from './rollup_data_enricher';
import { IndexPatternsFetcher } from './shared_imports';
import { handleEsError } from './shared_imports';
import { formatEsError } from './lib/format_es_error';
import { RollupConfig } from './config';
export class RollupPlugin implements Plugin<void, void, any, any> {
private readonly config: RollupConfig;
private readonly logger: Logger;
private readonly license: License;
constructor(initializerContext: PluginInitializerContext) {
this.config = initializerContext.config.get();
this.logger = initializerContext.logger.get();
this.license = new License();
}
@ -100,11 +103,14 @@ export class RollupPlugin implements Plugin<void, void, any, any> {
}
}
if (indexManagement && indexManagement.indexDataEnricher) {
indexManagement.indexDataEnricher.add(rollupDataEnricher);
if (this.config.ui.enabled) {
if (indexManagement && indexManagement.indexDataEnricher) {
indexManagement.indexDataEnricher.add(rollupDataEnricher);
}
dataViews.enableRollups();
data.search.enableRollups();
}
dataViews.enableRollups();
data.search.enableRollups();
}
start() {}

View file

@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { FtrConfigProviderContext } from '@kbn/test';
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const functionalConfig = await readConfigFile(require.resolve('../../config.ts'));
return {
...functionalConfig.getAll(),
testFiles: [require.resolve('.')],
kbnTestServer: {
...functionalConfig.get('kbnTestServer'),
serverArgs: [
...functionalConfig.get('kbnTestServer.serverArgs'),
// disable the UIs of plugins that add index data enrichers
`--xpack.rollup.ui.enabled=false`,
`--xpack.ccr.ui.enabled=false`,
`--xpack.ilm.ui.enabled=false`,
],
},
};
}

View file

@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { FtrProviderContext } from '../../../../ftr_provider_context';
export default ({ loadTestFile }: FtrProviderContext) => {
describe('Index Management: disabled data enrichers', function () {
loadTestFile(require.resolve('./indices'));
});
};

View file

@ -0,0 +1,50 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import expect from '@kbn/expect';
import { API_BASE_PATH, Index } from '@kbn/index-management-plugin/common';
import { FtrProviderContext } from '../../../../ftr_provider_context';
import { sortedExpectedIndexKeys } from '../constants';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('es');
const esDeleteAllIndices = getService('esDeleteAllIndices');
const createIndex = async (name: string) => {
await es.indices.create({ index: name });
};
const testIndex = 'test_index';
describe('GET indices without data enrichers', async () => {
before(async () => {
await createIndex(testIndex);
});
after(async () => {
await esDeleteAllIndices([testIndex]);
});
it(`doesn't send ILM, CCR and Rollups requests`, async () => {
const { body: indices } = await supertest
.get(`${API_BASE_PATH}/indices`)
.set('kbn-xsrf', 'xxx')
.expect(200);
const index = indices.find((item: Index) => item.name === testIndex);
const sortedReceivedKeys = Object.keys(index).sort();
let expectedKeys = [...sortedExpectedIndexKeys];
// no CCR data enricher
expectedKeys = expectedKeys.filter((item) => item !== 'isFollowerIndex');
// no ILM data enricher
expectedKeys = expectedKeys.filter((item) => item !== 'ilm');
// no Rollups data enricher
expectedKeys = expectedKeys.filter((item) => item !== 'isRollupIndex');
expect(sortedReceivedKeys).to.eql(expectedKeys);
});
});
}