Skip to content
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

[Fleet] Remove field package_policies from agent policy #138677

Conversation

nchaulet
Copy link
Member

@nchaulet nchaulet commented Aug 11, 2022

Summary

Resolve #137005

That PR remove the bi directionnal foreign key between agent policy and package policy.
Why?
That key was causing some issue when concurrent package policies are created, and it happens that the key was out of sync between the two index package-policies and agent-policies. By removing that package_policies key in the agent policy document we make our APIs more robust.

Now to retrieve the package policy for an agent policy we search for all the package policy with policy_id:"agent_policy_id"

This is breaking change, but it should be mitigated in the plugin using that field by the introduction of a bulk GET api for agent and package policy.

Release note

Breaking change remove the package_policies field from the agent policy saved object.

@nchaulet nchaulet self-assigned this Aug 11, 2022
@nchaulet nchaulet added Team:Fleet Team label for Observability Data Collection Fleet team release_note:breaking v8.5.0 labels Aug 22, 2022
@nchaulet nchaulet marked this pull request as ready for review August 22, 2022 17:34
@nchaulet nchaulet requested review from a team as code owners August 22, 2022 17:34
@nchaulet nchaulet requested review from pzl and paul-tavares August 22, 2022 17:34
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Aug 22, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@pzl pzl requested review from dasansol92 and removed request for pzl August 22, 2022 17:35
@nchaulet
Copy link
Member Author

@elasticmachine merge upstream

Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making all those chances on the Endpoint side. They LGTM 👍

@@ -35,7 +35,7 @@ export interface NewAgentPolicy {
export interface AgentPolicy extends Omit<NewAgentPolicy, 'id'> {
id: string;
status: ValueOf<AgentPolicyStatus>;
package_policies: string[] | PackagePolicy[];
package_policies?: PackagePolicy[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. I like that you still left this property around, since it can be useful sometimes to have it all in one API call.

@@ -16,14 +16,14 @@ import { PackagePoliciesTable } from './package_policies_table';
export const PackagePoliciesView = memo<{ agentPolicy: AgentPolicy }>(({ agentPolicy }) => {
useBreadcrumbs('policy_details', { policyName: agentPolicy.name });

if (agentPolicy.package_policies.length === 0) {
if (!agentPolicy.package_policies || agentPolicy.package_policies.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: there is a shorter way with lodash: isEmpty(agentPolicy.package_policies)

Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fleet change LGTM, added some comments

@nchaulet nchaulet requested review from orouz and sorenlouv August 23, 2022 12:14
Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APM changes LGTM

Copy link
Contributor

@orouz orouz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloud posture LGTM 👍

also noticed UI changed in integration policies table:

Screen Shot 2022-08-23 at 13 56 14

looks like this has no hits now:

@nchaulet
Copy link
Member Author

also noticed UI changed in integration policies table:

Good catch just pushed a change that should fix that

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fleet 866 872 +6

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 865.8KB 865.6KB -184.0B
securitySolution 5.4MB 5.4MB +201.0B
total +17.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
fleet 9 10 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 105.5KB 105.5KB -24.0B

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/saved-objects-service.html#_mappings

id before after diff
ingest-agent-policies 19 18 -1
Unknown metric groups

API count

id before after diff
fleet 961 967 +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @nchaulet

@nchaulet nchaulet merged commit 368eba6 into elastic:main Aug 23, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Aug 23, 2022
@nchaulet nchaulet deleted the feature-remove-package-policies-double-foreign-key branch August 23, 2022 22:19
Mpdreamz pushed a commit to Mpdreamz/kibana that referenced this pull request Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:breaking Team:APM All issues that need APM UI Team support Team:Fleet Team label for Observability Data Collection Fleet team v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Make packagePolicy.create more robust to concurrent calls
8 participants