Skip to content

Commit

Permalink
Make Agentless Connectors task handle connector.deleted properly (#20…
Browse files Browse the repository at this point in the history
…6606)

## Summary

This PR makes it so that the Agentless Kibana task implemented in
#203973 properly handles
soft-deleted connectors.

This helps with the situation when an integration policy has been
created for an agentless connector but a connector record has not yet
been created by an agentless host.

With current Kibana task implementation it could lead to the Policy
being deleted.

With this change, only policies that refer to soft-deleted connectors
will be cleaned up.

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [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
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
artem-shelkovnikov and kibanamachine authored Jan 16, 2025
1 parent 3e1391f commit f2a7d90
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('createConnectorDocument', () => {
api_key_secret_id: null,
configuration: {},
custom_scheduling: {},
deleted: false,
description: null,
error: null,
features: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function createConnectorDocument({
configuration: configuration || {},
custom_scheduling: {},
description: null,
deleted: false,
error: null,
features: features || null,
filtering: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export const fetchConnectors = async (
client: ElasticsearchClient,
indexNames?: string[],
fetchOnlyCrawlers?: boolean,
searchQuery?: string
searchQuery?: string,
includeDeleted?: boolean
): Promise<Connector[]> => {
const q = searchQuery && searchQuery.length > 0 ? searchQuery : undefined;

Expand All @@ -82,6 +83,7 @@ export const fetchConnectors = async (
...querystring,
from: accumulator.length,
size: 1000,
include_deleted: includeDeleted,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export interface Connector {
id: string;
index_name: string | null;
is_native: boolean;
deleted: boolean | null;
language: string | null;
last_access_control_sync_error: string | null;
last_access_control_sync_scheduled_at: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const indices: ElasticsearchIndexWithIngestion[] = [
name: '',
},
},
deleted: false,
description: null,
error: null,
features: null,
Expand Down Expand Up @@ -189,6 +190,7 @@ export const indices: ElasticsearchIndexWithIngestion[] = [
name: '',
},
},
deleted: false,
description: null,
error: null,
features: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const connectorIndex: ConnectorViewIndex = {
name: '',
},
},
deleted: false,
description: null,
error: null,
features: null,
Expand Down Expand Up @@ -199,6 +200,7 @@ export const crawlerIndex: CrawlerViewIndex = {
name: '',
},
},
deleted: false,
description: null,
error: null,
features: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const mockConnector: Connector = {
},
},
custom_scheduling: {},
deleted: false,
description: 'test',
error: null,
features: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ const mockConnector: Connector = {
api_key_secret_id: '',
configuration: {},
custom_scheduling: {},
deleted: false,
description: null,
error: null,
features: {
incremental_sync: {
document_level_security: {
enabled: true,
},
document_level_security: {
incremental_sync: {
enabled: true,
},
},
description: null,
error: null,
filtering: [],
id: '',
index_name: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('recreateConnectorDocument lib function', () => {
api_key_secret_id: null,
configuration: {},
custom_scheduling: {},
deleted: false,
description: null,
error: null,
features: null,
Expand Down
Loading

0 comments on commit f2a7d90

Please sign in to comment.