mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Enterprise Search] Remove access control as well if exists (#161122)
## Summary - Add access control remove - Deletes access control index too after content index is deleted. ### Checklist Delete any items that are not applicable to this PR. - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
54e613b1d9
commit
472d843fbc
3 changed files with 25 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* 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 { isIndexNotFoundException } from '@kbn/core-saved-objects-migration-server-internal';
|
||||
import { IScopedClusterClient } from '@kbn/core/server';
|
||||
|
||||
import { CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX } from '../..';
|
||||
|
||||
export const deleteAccessControlIndex = async (client: IScopedClusterClient, index: string) => {
|
||||
try {
|
||||
await client.asCurrentUser.indices.delete({
|
||||
index: index.replace('search-', CONNECTORS_ACCESS_CONTROL_INDEX_PREFIX),
|
||||
});
|
||||
} catch (e) {
|
||||
// Gracefully exit if index not found. This is a valid case.
|
||||
if (!isIndexNotFoundException(e)) throw e;
|
||||
}
|
||||
};
|
|
@ -26,6 +26,7 @@ import { fetchConnectorByIndexName, fetchConnectors } from '../../lib/connectors
|
|||
import { fetchCrawlerByIndexName, fetchCrawlers } from '../../lib/crawler/fetch_crawlers';
|
||||
|
||||
import { createIndex } from '../../lib/indices/create_index';
|
||||
import { deleteAccessControlIndex } from '../../lib/indices/delete_access_control_index';
|
||||
import { indexOrAliasExists } from '../../lib/indices/exists_index';
|
||||
import { fetchIndex } from '../../lib/indices/fetch_index';
|
||||
import { fetchIndices, fetchSearchIndices } from '../../lib/indices/fetch_indices';
|
||||
|
@ -201,6 +202,7 @@ export function registerIndexRoutes({
|
|||
}
|
||||
|
||||
await deleteIndexPipelines(client, indexName);
|
||||
await deleteAccessControlIndex(client, indexName);
|
||||
|
||||
await client.asCurrentUser.indices.delete({ index: indexName });
|
||||
|
||||
|
|
|
@ -61,5 +61,6 @@
|
|||
"@kbn/shared-ux-link-redirect-app",
|
||||
"@kbn/global-search-plugin",
|
||||
"@kbn/share-plugin",
|
||||
"@kbn/core-saved-objects-migration-server-internal",
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue