-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Use atomic agent and package policy API in cloud connector task #230011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use atomic agent and package policy API in cloud connector task #230011
Conversation
| try { | ||
| await agentlessAgentService.createAgentlessAgent(esClient, soClient, agentPolicy); | ||
| } catch (err) { | ||
| if (err instanceof AgentlessAgentCreateOverProvisionnedError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callout: I removed this conditional here, as it seems to be if we are creating an agentless agent policy, but fail to actually deploy it we should delete the policy so its not orphaned. I can't think of a case where we would want this to still stick around.
|
Pinging @elastic/fleet (Team:Fleet) |
|
Worth mentioning, when I'm not sure what causes this, and whether if its just something missing in my local setup Update: This is due to the |
x-pack/platform/plugins/shared/fleet/scripts/create_agents/create_agents.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/fleet/server/services/agent_policy.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/fleet/server/services/agent_policy.ts
Outdated
Show resolved
Hide resolved
juliaElastic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
History
|
| }; | ||
|
|
||
| public deployConnector = async (connector: ConnectorMetadata): Promise<PackagePolicy> => { | ||
| public deployConnector = async (connector: ConnectorMetadata) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: would be good to see a return type here Promise<AgentPolicyServiceInterface['createWithPackagePolicies']>
yansavitski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…tic#230011) ## Summary Resolves: elastic/ingest-dev#5821 * Adds to `AgentPolicyService` a `createWithPackagePolicies` method based on the implementation of the ` /internal/fleet/agent_and_package_policies` handler * Allows this functionality to be available from our plugin server API so it can be used outside user request contexts such as in background tasks.
…tic#230011) ## Summary Resolves: elastic/ingest-dev#5821 * Adds to `AgentPolicyService` a `createWithPackagePolicies` method based on the implementation of the ` /internal/fleet/agent_and_package_policies` handler * Allows this functionality to be available from our plugin server API so it can be used outside user request contexts such as in background tasks.
…tic#230011) ## Summary Resolves: elastic/ingest-dev#5821 * Adds to `AgentPolicyService` a `createWithPackagePolicies` method based on the implementation of the ` /internal/fleet/agent_and_package_policies` handler * Allows this functionality to be available from our plugin server API so it can be used outside user request contexts such as in background tasks.
Summary
Resolves: https://github.com/elastic/ingest-dev/issues/5821
AgentPolicyServiceacreateWithPackagePoliciesmethod based on the implementation of the/internal/fleet/agent_and_package_policieshandler (link)agent_and_package_policiesand would have added too much complexity.Steps
To reproduce issue on main:
Stack Management > Content Connectors > Create ConnectorOn this branch:
Run through the same steps above, but you should not get stuck on name collisions with existing policies. It should just keep failing on not being able to reach the agentless api.
If you want to observe a successful creation, you can mock the agentless api response by commenting out the agentless api request in and returning
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelinesbackport:*labels.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.