Skip to content

Commit

Permalink
[Rollups] Disable Rollups index data enricher if Rollups UI is disabl…
Browse files Browse the repository at this point in the history
…ed (#167295)

## Summary

Fixes #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)
  • Loading branch information
yuliacech authored Oct 4, 2023
1 parent 8a2843e commit 79411d9
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 24 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 19 additions & 20 deletions x-pack/plugins/rollup/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (isRollupUiEnabled) {
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 (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',
});
}

if (isRollupUiEnabled) {
dataViews.enableRollups();
const pluginName = i18n.translate('xpack.rollupJobs.appTitle', {
defaultMessage: 'Rollup Jobs',
Expand Down
14 changes: 10 additions & 4 deletions x-pack/plugins/rollup/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -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`,
],
},
};
}
Original file line number Diff line number Diff line change
@@ -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'));
});
};
Original file line number Diff line number Diff line change
@@ -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);
});
});
}

0 comments on commit 79411d9

Please sign in to comment.