[Connectors] Removing index name should not remove connector (#183833)

In `Search indices` table, if you delete an index with a connector
attached to it, it deletes both of them.
This was the normally accepted behaviour but with 8.13 we decouple the
connector and index.

Ideally deleting and index should only delete index and not touch
connector attached to it. Similar to the behaviour on `Connectors`
table.

The connector is not deleted, instead the referenced (deleted) index is
detached from connector so that user gets the warning that they need to
reconfigure the index once they navigate to connectors overview.

We are still removing api keys and connector secrets associated with the
deleted index. They need to be regenerated in the connector
configuration tab.
This commit is contained in:
Jedr Blaszyk 2024-05-21 14:50:21 +02:00 committed by GitHub
parent 68becd28df
commit cb127727b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View file

@ -12,7 +12,7 @@ import { ElasticsearchClient } from '@kbn/core/server';
export const updateConnectorIndexName = async (
client: ElasticsearchClient,
connectorId: string,
indexName: string
indexName: string | null
): Promise<Result> => {
return await client.transport.request<Result>({
method: 'PUT',

View file

@ -14,7 +14,7 @@ import { schema } from '@kbn/config-schema';
import { i18n } from '@kbn/i18n';
import { deleteConnectorById, deleteConnectorSecret } from '@kbn/search-connectors';
import { deleteConnectorSecret, updateConnectorIndexName } from '@kbn/search-connectors';
import {
fetchConnectorByIndexName,
fetchConnectors,
@ -207,7 +207,8 @@ export function registerIndexRoutes({
}
if (connector) {
await deleteConnectorById(client.asCurrentUser, connector.id);
// detach the deleted index without removing the connector
await updateConnectorIndexName(client.asCurrentUser, connector.id, null);
if (connector.api_key_id) {
await client.asCurrentUser.security.invalidateApiKey({ ids: [connector.api_key_id] });
}