-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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>
- Loading branch information
1 parent
54e613b
commit 472d843
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
x-pack/plugins/enterprise_search/server/lib/indices/delete_access_control_index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters