Skip to content

Commit

Permalink
set mapping to dynamic before calling migration endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Feb 7, 2020
1 parent ec1a4ab commit d72d774
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/es_archiver/actions/empty_kibana_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export async function emptyKibanaIndexAction({
const stats = createStats('emptyKibanaIndex', log);

await deleteKibanaIndices({ client, stats, log });
await migrateKibanaIndex({ kbnClient });
await migrateKibanaIndex({ client, kbnClient });
return stats;
}
2 changes: 1 addition & 1 deletion src/es_archiver/actions/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export async function loadAction({

// If we affected the Kibana index, we need to ensure it's migrated...
if (Object.keys(result).some(k => k.startsWith('.kibana'))) {
await migrateKibanaIndex({ kbnClient });
await migrateKibanaIndex({ client, kbnClient });

if (kibanaPluginIds.includes('spaces')) {
await createDefaultSpace({ client, index: '.kibana' });
Expand Down
17 changes: 16 additions & 1 deletion src/es_archiver/lib/indices/kibana_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,22 @@ export async function deleteKibanaIndices({
* builds up an object that implements just enough of the kbnMigrations interface
* as is required by migrations.
*/
export async function migrateKibanaIndex({ kbnClient }: { kbnClient: KbnClient }) {
export async function migrateKibanaIndex({
client,
kbnClient,
}: {
client: Client;
kbnClient: KbnClient;
}) {
// we allow dynamic mappings on the index, as some interceptors are accessing documents before
// the migration is actually performed. The migrator will put the value back to `strict` after migration.
await client.indices.putMapping({
index: '.kibana',
body: {
dynamic: true,
},
} as any);

return await kbnClient.savedObjects.migrate();
}

Expand Down

0 comments on commit d72d774

Please sign in to comment.