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 preconfiguration variable values #119749

Merged
merged 6 commits into from
Nov 29, 2021

Conversation

nchaulet
Copy link
Member

@nchaulet nchaulet commented Nov 25, 2021

Summary

Resolve #119748

When we introduced the package upgrade we reused and modified the overrideInputs function that was created to be used for preconfiguration function but we want to different behavior for preconfiguration and upgrade. This resulted in a bug where the values provided by the user for preconfiguration are not used.

That PR fix that by splitting the overrideInputs in two different function updatePackageInputs and preconfigurePackageInputs.

@nchaulet nchaulet added bug Fixes for quality problems that affect the customer experience v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team auto-backport Deprecated - use backport:version if exact versions are needed v7.16.0 v8.1.0 v7.16.1 labels Nov 25, 2021
@nchaulet nchaulet self-assigned this Nov 25, 2021
@nchaulet
Copy link
Member Author

@elasticmachine merge upstream

@nchaulet nchaulet requested a review from kpollich November 28, 2021 23:42
@nchaulet nchaulet marked this pull request as ready for review November 28, 2021 23:42
@nchaulet nchaulet requested a review from a team as a code owner November 28, 2021 23:42
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@nchaulet
Copy link
Member Author

@elasticmachine merge upstream

@@ -1171,7 +1169,110 @@ export function overridePackageInputs(
return resultingPackagePolicy;
}

function deepMergeVars(original: any, override: any): any {
export function preconfigurePackageInputs(
Copy link
Contributor

Choose a reason for hiding this comment

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

could these new functions be moved to separate files? this service is more than 1000 lines long.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I think it will make sense to refactorize this whole service, I am going to create a follow up issue to that if it's correct for you?

Copy link
Member Author

Choose a reason for hiding this comment

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

I created that issue here #119844

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks!

],
};

const packageInfo: PackageInfo = {
Copy link
Contributor

Choose a reason for hiding this comment

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

it takes a lot of code to set up these objects. could we extract default values to a common place and only override the specific parts for a test?

Copy link
Member Author

Choose a reason for hiding this comment

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

If we refactorize the package policy we will have to refactorize the tests and it will probably a better time to create these fixture functions, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, agree

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.

Definitely a welcome change. Having a single code path try to account for multiple use cases around applying policy values (upgrades vs preconfiguration) was a poor implementation choice out of the gate. Having two distinct implementations here is much more stable and avoids nasty bugs with our policy merging logic.

The other review comments look good to me, so I'll approve for once those are addressed.

🚀

@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 @nchaulet

@nchaulet nchaulet removed the v7.16.0 label Nov 29, 2021
@nchaulet nchaulet merged commit 9f47e38 into elastic:main Nov 29, 2021
@nchaulet nchaulet deleted the fix-119748-preconfiguration-value branch November 29, 2021 19:13
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 29, 2021
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
8.0
7.16 Commit could not be cherrypicked due to conflicts

Successful backport PRs will be merged automatically after passing CI.

To backport manually run:
node scripts/backport --pr 119749

kibanamachine added a commit that referenced this pull request Nov 29, 2021
nchaulet added a commit to nchaulet/kibana that referenced this pull request Nov 30, 2021
# Conflicts:
#	x-pack/plugins/fleet/server/services/preconfiguration.ts
nchaulet added a commit that referenced this pull request Nov 30, 2021
* [Fleet] Fix preconfiguration variable values (#119749)

# Conflicts:
#	x-pack/plugins/fleet/server/services/preconfiguration.ts

* Fix merge issue

* Fix merge issue
TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 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 bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.16.1 v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Fleet preconfigured variable value is not used
7 participants