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 managed agent policy preconfiguration update #181624

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

nchaulet
Copy link
Member

@nchaulet nchaulet commented Apr 24, 2024

Summary

Managed agent policy defined in the kibana config should be updated, if there is a change in the kibana config. It seems if the saved object for that agent policy is out-of-sync and do not have the is_managed attribute correctly set we never update them. (This is causing some bug like with the keep_monitoring_alive flag added in 8.12).

That PR fix that by using the policy defined in the config and not the SO as source of truth.

Tests

Automated

I added unit test to the preconfiguration service

Manual

You can start kibana locally with the following config

xpack.fleet.agentPolicies:
  - name: Test policy
    description: TEST
    id: test-policy
    is_default: false
    is_default_fleet_server: false
    package_policies: []

Than update it to add is_managed and keep_monitoring_alive and verify your policy contains these fields

xpack.fleet.agentPolicies:
  - name: Test policy
    description: TEST
    id: test-policy
    is_default: false
    is_managed: true
    is_default_fleet_server: false
    package_policies: []
    keep_monitoring_alive: true

Questions

Should we add a release note for that?

@nchaulet nchaulet added the Team:Fleet Team label for Observability Data Collection Fleet team label Apr 24, 2024
@nchaulet nchaulet self-assigned this Apr 24, 2024
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@nchaulet
Copy link
Member Author

/ci

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Integration Tests #2 / Migration actions - serverless environment readWithPit returns a left es_response_too_large error when a read batch exceeds the maxResponseSize

Metrics [docs]

✅ unchanged

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

cc @nchaulet

@nchaulet nchaulet marked this pull request as ready for review April 24, 2024 22:50
@nchaulet nchaulet requested a review from a team as a code owner April 24, 2024 22:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@nchaulet nchaulet added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to the previous minor version (i.e. one version back from main) bug Fixes for quality problems that affect the customer experience labels Apr 24, 2024
Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

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

I think it would be good to flag this as a fix in release notes.

@juliaElastic juliaElastic added release_note:fix and removed release_note:skip Skip the PR/issue when compiling release notes labels Apr 25, 2024
@juliaElastic
Copy link
Contributor

Is the keep_monitoring_alive supposed to only work for managed policies? I'm wondering if we should allow it for other, non-managed policies too.

@nchaulet
Copy link
Member Author

Is the keep_monitoring_alive supposed to only work for managed policies? I'm wondering if we should allow it for other, non-managed policies too.

@juliaElastic I think nothing should prevent to setkeep_monitoring_alive for non managed policy it's available through the API, I am wondering what will be the use case but it should work.

@nchaulet nchaulet merged commit 4d674b1 into elastic:main Apr 25, 2024
31 checks passed
@nchaulet nchaulet deleted the fix-managed-policy-update branch April 25, 2024 11:28
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 25, 2024
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.14

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 25, 2024
) (#181699)

# Backport

This will backport the following commits from `main` to `8.14`:
- [[Fleet] Fix managed agent policy preconfiguration update
(#181624)](#181624)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nicolas
Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2024-04-25T11:28:22Z","message":"[Fleet]
Fix managed agent policy preconfiguration update
(#181624)","sha":"4d674b14cdfb7d9039bfa1c389701ba9ef1987a3","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Fleet","backport:prev-minor","v8.15.0"],"title":"[Fleet]
Fix managed agent policy preconfiguration
update","number":181624,"url":"#181624
Fix managed agent policy preconfiguration update
(#181624)","sha":"4d674b14cdfb7d9039bfa1c389701ba9ef1987a3"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"#181624
Fix managed agent policy preconfiguration update
(#181624)","sha":"4d674b14cdfb7d9039bfa1c389701ba9ef1987a3"}}]}]
BACKPORT-->

Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
@nchaulet
Copy link
Member Author

💚 All backports created successfully

Status Branch Result
8.13

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

nchaulet added a commit to nchaulet/kibana that referenced this pull request Apr 25, 2024
)

(cherry picked from commit 4d674b1)

# Conflicts:
#	x-pack/plugins/fleet/common/types/models/agent_policy.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to the previous minor version (i.e. one version back from main) bug Fixes for quality problems that affect the customer experience release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team v8.13.3 v8.14.0 v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants