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] Fix - Increment system package name when adding agent policy with monitoring #118403

Merged
merged 1 commit into from
Nov 15, 2021

Conversation

criamico
Copy link
Contributor

@criamico criamico commented Nov 11, 2021

Closes #118357

Summary

Adding an agent policy with "Collect system logs and metric" checkbox enabled triggers the error There is already a package with the same name

This bug was caused by the unique names PR: when we add a new agent policy with the system monitoring enabled we automatically install the system package, but the name given to the integration was always the same (system-1). Since we are now checking that all the integration packages have a unique name, the installation fails with the above error.

In this PR I'm adding a function that fetches all the system integrations already installed and increment the name, like it was done in the previous PR.

Steps to reproduce:

  1. Navigate to "add agent policy" fly out
  2. If it's the first time you set up the system, add an agent policy with name test , otherwise go to step 3
  3. Now add another agent policy with name test2, or any other name as long as is unique with "Collect system logs and metric" checked
  4. The agent policy should be created properly and contain the system integration with incremental name format (something like system-1, system-2...)

Checklist

For maintainers

@criamico criamico added v8.0.0 Team:Fleet Team label for Observability Data Collection Fleet team auto-backport Deprecated - use backport:version if exact versions are needed labels Nov 11, 2021
@criamico criamico self-assigned this Nov 11, 2021
@criamico criamico marked this pull request as ready for review November 15, 2021 09:55
@criamico criamico requested a review from a team as a code owner November 15, 2021 09:55
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico criamico added the release_note:skip Skip the PR/issue when compiling release notes label Nov 15, 2021
? systemPackagePolicyData.items
.filter((ds) => Boolean(ds.name.match(pkgPoliciesNamePattern)))
.map((ds) => parseInt(ds.name.match(pkgPoliciesNamePattern)![1], 10))
.sort((a, b) => a - b)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I don't think the sort implementation is necessary?

Suggested change
.sort((a, b) => a - b)
.sort()

Copy link
Member

@kpollich kpollich left a comment

Choose a reason for hiding this comment

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

LGTM w/ one minor nit

x-pack/plugins/fleet/server/services/package_policy.ts Outdated Show resolved Hide resolved
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

cc @criamico

@criamico criamico merged commit fe2498c into elastic:main Nov 15, 2021
@criamico criamico deleted the fix_agent_policy_unique branch November 15, 2021 15:07
@kibanamachine
Copy link
Contributor

The following labels were identified as gaps in your version labels and will be added automatically:

  • v8.1.0

If any of these should not be on your pull request, please manually remove them.

@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
8.0
7.16

The backport PRs will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Nov 15, 2021
…with monitoring (#118403) (#118545)

Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Nov 15, 2021
…with monitoring (#118403) (#118546)

Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
fkanout pushed a commit to fkanout/kibana that referenced this pull request Nov 17, 2021
mbondyra pushed a commit to mbondyra/kibana that referenced this pull request Nov 19, 2021
dmlemeshko pushed a commit that referenced this pull request Nov 29, 2021
roeehub pushed a commit to build-security/kibana that referenced this pull request Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.16.0 v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Adding an agent policy with a unique name triggers an error
6 participants