Skip to content

Commit

Permalink
[Search Connectors] : Unregister Kibana background task (elastic#211091)
Browse files Browse the repository at this point in the history
## Summary

Since Agentless Connectors will not be released in 9.0 anymore, this PR
should unregister and stop the background kibana task from creating new
policies for elastic-managed connectors.

### Closes elastic/search-team#9283

### 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
- [ ] [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
- [x] 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)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 18, 2025
1 parent f5c9529 commit 8f3a45f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export const REMOVED_TYPES: string[] = [
// deprecated in https://github.com/elastic/kibana/pull/121442
'alerting:siem.signals',

// deprecated in https://github.com/elastic/kibana/pull/211091
'search:agentless-connectors-manager',

'search_sessions_monitor',
'search_sessions_cleanup',
'search_sessions_expire',
Expand Down
60 changes: 2 additions & 58 deletions x-pack/solutions/search/plugins/search_connectors/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@
* 2.0.
*/

import type {
PluginInitializerContext,
Plugin,
CoreStart,
CoreSetup,
Logger,
} from '@kbn/core/server';
import type { PluginInitializerContext, Plugin, CoreSetup } from '@kbn/core/server';
import { ConnectorServerSideDefinition } from '@kbn/search-connectors';
import { isAgentlessEnabled } from '@kbn/fleet-plugin/server/services/utils/agentless';
import { getConnectorTypes } from '../common/lib/connector_types';
import type {
SearchConnectorsPluginSetup as SearchConnectorsPluginSetup,
Expand All @@ -22,9 +15,6 @@ import type {
SearchConnectorsPluginStartDependencies,
} from './types';

import { AgentlessConnectorDeploymentsSyncService } from './task';
import { SearchConnectorsConfig } from './config';

export class SearchConnectorsPlugin
implements
Plugin<
Expand All @@ -35,19 +25,9 @@ export class SearchConnectorsPlugin
>
{
private connectors: ConnectorServerSideDefinition[];
private log: Logger;
private readonly config: SearchConnectorsConfig;
private agentlessConnectorDeploymentsSyncService: AgentlessConnectorDeploymentsSyncService;
private isServerless: boolean;

constructor(initializerContext: PluginInitializerContext) {
this.connectors = [];
this.log = initializerContext.logger.get();
this.config = initializerContext.config.get();
this.agentlessConnectorDeploymentsSyncService = new AgentlessConnectorDeploymentsSyncService(
this.log
);
this.isServerless = false;
}

public setup(
Expand All @@ -57,49 +37,13 @@ export class SearchConnectorsPlugin
const http = coreSetup.http;

this.connectors = getConnectorTypes(http.staticAssets);
this.isServerless = plugins.cloud && plugins.cloud.isServerlessEnabled;
const coreStartServices = coreSetup.getStartServices();

// There seems to be no way to check for agentless here
// So we register a task, but do not execute it in `start` method
this.log.debug('Registering agentless connectors infra sync task');

coreStartServices
.then(([coreStart, searchConnectorsPluginStartDependencies]) => {
this.agentlessConnectorDeploymentsSyncService.registerInfraSyncTask(
plugins,
coreStart,
searchConnectorsPluginStartDependencies
);
})
.catch((err) => {
this.log.error(`Error registering agentless connectors infra sync task`, err);
});

return {
getConnectorTypes: () => this.connectors,
};
}

public start(coreStart: CoreStart, plugins: SearchConnectorsPluginStartDependencies) {
if (this.isServerless) {
this.log.info(
'Serverless is not supported, skipping agentless connectors infrastructure watcher task'
);
} else if (isAgentlessEnabled()) {
this.log.info(
'Agentless is supported, scheduling initial agentless connectors infrastructure watcher task'
);
this.agentlessConnectorDeploymentsSyncService
.scheduleInfraSyncTask(this.config, plugins.taskManager)
.catch((err) => {
this.log.error(`Error scheduling agentless connectors infra sync task`, err);
});
} else {
this.log.info(
'Agentless is not supported, skipping scheduling initial agentless connectors infrastructure watcher task'
);
}
public start() {
return {
getConnectors: () => this.connectors,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export default function ({ getService }: FtrProviderContext) {
'osquery:telemetry-saved-queries',
'report:execute',
'risk_engine:risk_scoring',
'search:agentless-connectors-manager',
'security-solution-ea-asset-criticality-ecs-migration',
'security:endpoint-diagnostics',
'security:endpoint-meta-telemetry',
Expand Down

0 comments on commit 8f3a45f

Please sign in to comment.