-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 bug with duplicate Fleet Server inputs in Cloud deployments #119925
[Fleet] Fix bug with duplicate Fleet Server inputs in Cloud deployments #119925
Conversation
Rework logic around looking up `originalInput` value to handle cases in which `policy_template` is `undefined` on the policy's input object.
Pinging @elastic/fleet (Team:Fleet) |
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.
Looks good to me, I tested an upgrade and it seems to fix the issue 🚀 we already have some unit test to that function maybe we can add this scenario
Good call. I will add some tests here tomorrow morning and then this should be good to land. I don't think this will be easy to backport to 7.16.x because of refactoring in this file - are we okay with this or do we need a "manual backport" fix to land in a patch release for 7.16? |
Added tests in 98adb6c |
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @kpollich |
Waiting on #119971 to land then adding backport label for 7.16 to this |
…ts (elastic#119925) * Fix bug with duplicate Fleet Server inputs Rework logic around looking up `originalInput` value to handle cases in which `policy_template` is `undefined` on the policy's input object. * Set policy_template when possible * Add tests for duplicate input case
…ts (elastic#119925) * Fix bug with duplicate Fleet Server inputs Rework logic around looking up `originalInput` value to handle cases in which `policy_template` is `undefined` on the policy's input object. * Set policy_template when possible * Add tests for duplicate input case
…ts (#119925) (#120014) * Fix bug with duplicate Fleet Server inputs Rework logic around looking up `originalInput` value to handle cases in which `policy_template` is `undefined` on the policy's input object. * Set policy_template when possible * Add tests for duplicate input case Co-authored-by: Kyle Pollich <[email protected]>
…ts (#119925) (#120015) * Fix bug with duplicate Fleet Server inputs Rework logic around looking up `originalInput` value to handle cases in which `policy_template` is `undefined` on the policy's input object. * Set policy_template when possible * Add tests for duplicate input case Co-authored-by: Kyle Pollich <[email protected]>
…ts (elastic#119925) * Fix bug with duplicate Fleet Server inputs Rework logic around looking up `originalInput` value to handle cases in which `policy_template` is `undefined` on the policy's input object. * Set policy_template when possible * Add tests for duplicate input case
Summary
Fixes #119523
Fixes a bug in our input lookup logic that causes us to create duplicate
fleet-server
inputs on package policies when upgrading policies in Elastic Cloud created in v7.13.The root cause here was our lookup logic in cases where
policy_template
wasundefined
on a package policy inputs. When the "incoming" input has apolicy_template
and we don't find an existing input withpolicy_template
at all (not just a mismatched template), we should use that existing input. This guarantees that policies from Kibana versions prior to #101531 in whichpolicy_template
was not always provided can still be upgraded.How to test
package_to_package_policy.ts
to prevent package policies from havingpolicy_template
set at all.kibana.dev.yml
to mimic the "Elastic Agent on Cloud" policy we use in Cloud:From a clean Elasticsearch snapshot, start up and Kibana and ensure Fleet setup completes successfully
Stash your changes to
package_to_package_policy.ts
or uncomment the code above. We just need this commented out during setup to reproduce the issue with the missingpolicy_template
value 🙂Grab the ID of the "Fleet Server" package policy under your "Elastic Agent on Cloud" agent policy from the Kibana UI, and run the following in dev tools to confirm that
policy_template
is not set:Update Fleet Server with "Upgrade integration policies" checked from the integration settings page.
Verify that the upgrade was successful, and that only a single
fleet_server
input is defined on the agent policyRun the same dev tools query as above, and confirm that the policy data now includes the expected
policy_template
value.