Skip to content

Commit

Permalink
[Fix] Load sample data in serverless (elastic#165157)
Browse files Browse the repository at this point in the history
## Summary

Closes elastic#165114
Closes elastic#165368


Unable to create sample data index "kibana_sample_data_flights", error:
illegal_argument_exception Root causes: illegal_argument_exception:
Settings [index.auto_expand_replicas,index.number_of_shards] are not
available when running in serverless mode

<img width="1441" alt="Screenshot 2023-08-30 at 11 21 03 AM"
src="https://github.com/elastic/kibana/assets/20343860/14f580f2-5dff-496f-907c-31007b3904f1">



found in
[logs](https://overview.qa.cld.elstc.co/s/appex/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:'2023-08-30T16:48:55.621Z',to:'2023-08-30T18:27:14.583Z'))&_a=(columns:!(),filters:!(),grid:(columns:(request_method.keyword:(width:814))),hideAggregatedPreview:!f,index:'2e3efa6b-bb9e-48a7-a1b5-af690e556a6b',interval:auto,query:(language:kuery,query:'kubernetes.labels.k8s_elastic_co%2Fproject-id:%20%22d660f827d17a4e3f9662d473461c099c%22%20'),sort:!(!('@timestamp',desc)),viewMode:aggregated))
in the message field when filtering by project by
kubernetes.labels.k8s_elastic_co/project-id:
"d660f827d17a4e3f9662d473461c099c"

- [x] TODO set up FTR that should have caught this to confirm this fix
works in serverless environments (based off the home page object)

---------
Co-authored-by: Sébastien Loix <[email protected]>
  • Loading branch information
rshen91 authored Sep 8, 2023
1 parent 4c2f702 commit 41b124d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,14 @@ describe('SampleDataInstaller', () => {
expect(esClient.asCurrentUser.indices.create).toHaveBeenCalledWith({
index: 'kibana_sample_data_test_single_data_index',
body: {
settings: { index: { number_of_shards: 1, auto_expand_replicas: '0-1' } },
mappings: { properties: { someField: { type: 'keyword' } } },
mappings: {
properties: {
someField: { type: 'keyword' },
},
},
settings: {
index: {},
},
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ export class SampleDataInstaller {

private async installDataIndex(dataset: SampleDatasetSchema, dataIndex: DataIndexSchema) {
const index = createIndexName(dataset.id, dataIndex.id);

try {
if (dataIndex.isDataStream) {
const request = {
name: index,
body: {
template: {
settings: { number_of_shards: 1, auto_expand_replicas: '0-1' },
mappings: { properties: dataIndex.fields },
},
index_patterns: [index],
Expand All @@ -180,8 +180,6 @@ export class SampleDataInstaller {
settings: {
index: {
...dataIndex.indexSettings,
number_of_shards: 1,
auto_expand_replicas: '0-1',
},
},
mappings: { properties: dataIndex.fields },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 'expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['settings', 'common', 'header', 'home']);

describe('Sample data in serverless', function () {
it('Sample data loads', async () => {
await PageObjects.home.addSampleDataSet('ecommerce');
const ecommerce = await PageObjects.home.isSampleDataSetInstalled('ecommerce');
expect(ecommerce).toBe(true);
});
});
}

0 comments on commit 41b124d

Please sign in to comment.