Skip to content

Commit 22d3e62

Browse files
author
Dmitrii Shevchenko
authored
[Fleet] Added default index pattern creation to stream-based installation (#199122)
**Related to: #195888 ## Summary Add default index pattern creation to the new stream-based package installation method to match the behavior of standard package installation. Switching to stream-based package installation resulted in the default index patterns not being created, even after installing the rules package. While this likely doesn’t affect production, as multiple integrations are usually installed in Kibana (creating the default index pattern in any case), this change has impacted some tests: #199030. So restoring the original behaviour
1 parent 7c92a10 commit 22d3e62

4 files changed

Lines changed: 28 additions & 22 deletions

File tree

x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,20 @@ export async function installKibanaAssets(options: {
133133
return [];
134134
}
135135

136+
await createDefaultIndexPatterns(savedObjectsImporter);
137+
await makeManagedIndexPatternsGlobal(savedObjectsClient);
138+
139+
return await installKibanaSavedObjects({
140+
logger,
141+
savedObjectsImporter,
142+
kibanaAssets: assetsToInstall,
143+
assetsChunkSize: MAX_ASSETS_TO_INSTALL_IN_PARALLEL,
144+
});
145+
}
146+
147+
export async function createDefaultIndexPatterns(
148+
savedObjectsImporter: SavedObjectsImporterContract
149+
) {
136150
// Create index patterns separately with `overwrite: false` to prevent blowing away users' runtime fields.
137151
// These don't get retried on conflict, because we expect that they exist once an integration has been installed.
138152
const indexPatternSavedObjects = getIndexPatternSavedObjects() as ArchiveAsset[];
@@ -143,15 +157,6 @@ export async function installKibanaAssets(options: {
143157
refresh: false,
144158
managed: true,
145159
});
146-
147-
await makeManagedIndexPatternsGlobal(savedObjectsClient);
148-
149-
return await installKibanaSavedObjects({
150-
logger,
151-
savedObjectsImporter,
152-
kibanaAssets: assetsToInstall,
153-
assetsChunkSize: MAX_ASSETS_TO_INSTALL_IN_PARALLEL,
154-
});
155160
}
156161

157162
export async function installKibanaAssetsAndReferencesMultispace({

x-pack/plugins/fleet/server/services/epm/kibana/assets/install_with_streaming.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
* 2.0.
66
*/
77

8-
import type { SavedObject, SavedObjectsClientContract } from '@kbn/core/server';
8+
import type { SavedObjectsClientContract } from '@kbn/core/server';
99

10-
import type { Installation, PackageInstallContext } from '../../../../../common/types';
10+
import type { PackageInstallContext } from '../../../../../common/types';
1111
import type { KibanaAssetReference, KibanaAssetType } from '../../../../types';
1212
import { getPathParts } from '../../archive';
1313

1414
import { saveKibanaAssetsRefs } from '../../packages/install';
1515

16+
import { makeManagedIndexPatternsGlobal } from '../index_pattern/install';
17+
1618
import type { ArchiveAsset } from './install';
1719
import {
1820
KibanaSavedObjectTypeMapping,
21+
createDefaultIndexPatterns,
1922
createSavedObjectKibanaAsset,
2023
isKibanaAssetType,
2124
toAssetReference,
@@ -27,7 +30,6 @@ interface InstallKibanaAssetsWithStreamingArgs {
2730
packageInstallContext: PackageInstallContext;
2831
spaceId: string;
2932
savedObjectsClient: SavedObjectsClientContract;
30-
installedPkg?: SavedObject<Installation> | undefined;
3133
}
3234

3335
const MAX_ASSETS_TO_INSTALL_IN_PARALLEL = 100;
@@ -37,11 +39,14 @@ export async function installKibanaAssetsWithStreaming({
3739
packageInstallContext,
3840
savedObjectsClient,
3941
pkgName,
40-
installedPkg,
4142
}: InstallKibanaAssetsWithStreamingArgs): Promise<KibanaAssetReference[]> {
4243
const { archiveIterator } = packageInstallContext;
4344

44-
const { savedObjectClientWithSpace } = getSpaceAwareSaveobjectsClients(spaceId);
45+
const { savedObjectClientWithSpace, savedObjectsImporter } =
46+
getSpaceAwareSaveobjectsClients(spaceId);
47+
48+
await createDefaultIndexPatterns(savedObjectsImporter);
49+
await makeManagedIndexPatternsGlobal(savedObjectsClient);
4550

4651
const assetRefs: KibanaAssetReference[] = [];
4752
let batch: ArchiveAsset[] = [];

x-pack/plugins/fleet/server/services/epm/packages/install_state_machine/steps/step_install_kibana_assets.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function stepInstallKibanaAssets(context: InstallContext) {
4040
}
4141

4242
export async function stepInstallKibanaAssetsWithStreaming(context: InstallContext) {
43-
const { savedObjectsClient, installedPkg, packageInstallContext, spaceId } = context;
43+
const { savedObjectsClient, packageInstallContext, spaceId } = context;
4444
const { packageInfo } = packageInstallContext;
4545
const { name: pkgName } = packageInfo;
4646

@@ -51,7 +51,6 @@ export async function stepInstallKibanaAssetsWithStreaming(context: InstallConte
5151
savedObjectsClient,
5252
pkgName,
5353
packageInstallContext,
54-
installedPkg,
5554
spaceId,
5655
})
5756
);

x-pack/test/security_solution_cypress/cypress/e2e/investigations/sourcerer/sourcerer_timeline.cy.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ import { closeTimeline, openTimelineById } from '../../../tasks/timeline';
4040
const siemDataViewTitle = 'Security Default Data View';
4141
const dataViews = ['logs-*', 'metrics-*', '.kibana-event-log-*'];
4242

43-
// Failing: See https://github.com/elastic/kibana/issues/198943
44-
describe.skip('Timeline scope', { tags: ['@ess', '@serverless', '@skipInServerless'] }, () => {
43+
describe('Timeline scope', { tags: ['@ess', '@serverless', '@skipInServerless'] }, () => {
4544
before(() => {
4645
waitForRulesBootstrap();
4746
});
@@ -64,8 +63,7 @@ describe.skip('Timeline scope', { tags: ['@ess', '@serverless', '@skipInServerle
6463
});
6564

6665
describe('Modified badge', () => {
67-
// failing on main multiple times https://github.com/elastic/kibana/issues/198944#issuecomment-2457665138 and https://github.com/elastic/kibana/issues/198943#issuecomment-2457665072
68-
it.skip('Selecting new data view does not add a modified badge', () => {
66+
it('Selecting new data view does not add a modified badge', () => {
6967
openTimelineUsingToggle();
7068
cy.get(SOURCERER.badgeModified).should(`not.exist`);
7169
openSourcerer('timeline');
@@ -135,8 +133,7 @@ describe.skip('Timeline scope', { tags: ['@ess', '@serverless', '@skipInServerle
135133
});
136134

137135
const defaultPatterns = [`auditbeat-*`, `${DEFAULT_ALERTS_INDEX}-default`];
138-
// failing on main multiple times https://github.com/elastic/kibana/issues/198944#issuecomment-2457665138 and https://github.com/elastic/kibana/issues/198943#issuecomment-2457665072
139-
it.skip('alerts checkbox behaves as expected', () => {
136+
it('alerts checkbox behaves as expected', () => {
140137
isDataViewSelection(siemDataViewTitle);
141138
defaultPatterns.forEach((pattern) => isSourcererSelection(pattern));
142139
openDataViewSelection();

0 commit comments

Comments
 (0)