Skip to content

Commit

Permalink
[migrations] Disable replicas (#25274) (#25358)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Smalley <[email protected]>
  • Loading branch information
tylersmalley authored Nov 8, 2018
1 parent 2c00e4a commit fec203f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/server/saved_objects/migrations/core/call_cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ export interface IndexCreationOpts {
body?: {
mappings?: IndexMapping;
settings?: {
index: {
number_of_shards: string;
number_of_replicas: string;
};
number_of_shards: number;
auto_expand_replicas: string;
};
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ describe('ElasticIndex', () => {
test('calls indices.create', async () => {
const callCluster = sinon.spy(async (path: string, { body, index }: any) => {
expect(path).toEqual('indices.create');
expect(body).toEqual({ mappings: { foo: 'bar' } });
expect(body).toEqual({
mappings: { foo: 'bar' },
settings: { auto_expand_replicas: '0-1', number_of_shards: 1 },
});
expect(index).toEqual('.abcd');
});

Expand Down Expand Up @@ -248,6 +251,7 @@ describe('ElasticIndex', () => {
properties: { foo: 'bar' },
},
},
settings: { auto_expand_replicas: '0-1', number_of_shards: 1 },
});
expect(arg.index).toEqual('.ze-index');
return true;
Expand Down
6 changes: 4 additions & 2 deletions src/server/saved_objects/migrations/core/elastic_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { AliasAction, CallCluster, IndexMapping, NotFound, RawDoc } from './call
// tslint:disable-next-line:no-var-requires
const { getTypes } = require('../../../mappings');

const settings = { number_of_shards: 1, auto_expand_replicas: '0-1' };

export interface FullIndexInfo {
aliases: { [name: string]: object };
exists: boolean;
Expand Down Expand Up @@ -213,7 +215,7 @@ export async function createIndex(
index: string,
mappings?: IndexMapping
) {
await callCluster('indices.create', { body: { mappings }, index });
await callCluster('indices.create', { body: { mappings, settings }, index });
}

export async function deleteIndex(callCluster: CallCluster, index: string) {
Expand All @@ -236,7 +238,7 @@ export async function convertToAlias(
batchSize: number
) {
await callCluster('indices.create', {
body: { mappings: info.mappings },
body: { mappings: info.mappings, settings },
index: info.indexName,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe('IndexMigrator', () => {
},
},
},
settings: { number_of_shards: 1, auto_expand_replicas: '0-1' },
},
index: '.kibana_1',
});
Expand Down Expand Up @@ -197,6 +198,7 @@ describe('IndexMigrator', () => {
},
},
},
settings: { number_of_shards: 1, auto_expand_replicas: '0-1' },
},
index: '.kibana_2',
});
Expand Down

0 comments on commit fec203f

Please sign in to comment.