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 creation of POLICY_CHANGE action during 7.9 => 7.10 migration #81041

Merged
merged 4 commits into from
Oct 20, 2020

Conversation

nchaulet
Copy link
Member

@nchaulet nchaulet commented Oct 19, 2020

Summary

Resolve https://github.com/elastic/beats/issues/21904

In 7.10 we introduced an Agent action POLICY_CHANGE per policy instead of dynamically creating that action during the agent checkin.

But that action is not created for Policy previous to 7.10 until a change is made to the policy, this fix it by checkin in the ingest manager setup call if all the policy have a POLICY_CHANGE action.

How to reproduce the bug?

  1. Setup Kibana 7.9
  2. Create a policy and setup fleet
  3. setup kibana 7.10
  4. use an enrollment token previously create in 7.9 to enroll an agent => the agent will never receive a POLICY_CHANGE action.

@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 v7.10.0 Team:Fleet Team label for Observability Data Collection Fleet team v7.11.0 labels Oct 19, 2020
@nchaulet nchaulet requested a review from a team October 19, 2020 18:35
@nchaulet nchaulet self-assigned this Oct 19, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

const adminUser = await outputService.getAdminUser(soClient, false);
const outputId = await outputService.getDefaultOutputId(soClient);
// If admin user (fleet_enroll) and output id exist Agents are correctly setup
return adminUser !== null && outputId !== null;
Copy link
Contributor

Choose a reason for hiding this comment

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

this condition seems to differ from the original, where we just check for truthiness. is there a specific need to change to check for null instead?

Copy link
Member Author

@nchaulet nchaulet Oct 20, 2020

Choose a reason for hiding this comment

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

no there is no specific need I check for null to fix a type issue otherwise is not returning a boolean here, but I could replace it by

!!adminUser && !!outputId

@@ -80,6 +81,9 @@ async function createSetupSideEffects(
) {
throw new Error('Policy not found');
}

await ensureAgentActionPolicyChangeExists(soClient);
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it's a bit strange to have this function called in this order, in the middle of the logic for ensuring default packages for default policy. what do you think of moving it to L68, before the start of this logic, but after the rest of the ensure() methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

we probably want to have it after the package installation so the config contains the package I should probably move it L111

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

distributable file count

id before after diff
default 48035 48036 +1

History

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.10.0 v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants