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] Force unenroll in Agent activity #141208

Merged
merged 7 commits into from
Sep 22, 2022

Conversation

juliaElastic
Copy link
Contributor

@juliaElastic juliaElastic commented Sep 21, 2022

Summary

Fix #140794 and #140923

  • Added an action document with action results on force unenroll, so that Agent activity shows that force unenroll was successful.
  • On force unenroll, checking other non-expired unenroll actions and adding action results for agents that were force unenrolled, so that the unenroll action is not stuck in progress.

To verify:

  • unenroll a few agents with fleet server stopped
  • check in agent activity that there is an in progress unenroll activity
  • force unenroll the same agents
  • check in agent activity that the previous unenroll action shows up as completed
  • check that there is a completed force unenroll activity as well

image

image

Checklist

@juliaElastic juliaElastic added release_note:skip Skip the PR/issue when compiling release notes v8.5.0 labels Sep 21, 2022
@juliaElastic juliaElastic self-assigned this Sep 21, 2022
@juliaElastic juliaElastic requested a review from a team as a code owner September 21, 2022 11:13
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Sep 21, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

(options.revoke && agent.unenrolled_at) ||
(!options.revoke && (agent.unenrollment_started_at || agent.unenrolled_at))
) {
outgoingErrors[agent.id] = new FleetError(`Agent ${agent.id} already unenrolled`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the implementation of unenroll to be consistent with reassign: if an agent is already unenrolled, the action is set to failed for the agent.
Previously the unenrolled agents were filtered out, so the action didn't include them. This is problematic in agent activity, as those agents don't have any trace of being actioned.

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

Not tested locally but the code looks good to me 🚀

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.

Code LGTM and works as expected when testing locally. 🚀

const commonAgents = intersection(action.agents, agentIds);
if (commonAgents.length > 0) {
// filtering out agents with action results
const agentsToUpdate = await getAgentsWithoutActionResults(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added one more check to only update action results for those agents that do not yet have action results. This is to avoid having multiple result entries for the same action.
Did some measurements on 100k agent entries, and the unenroll took 24s without revoke and 31s with revoke.

@@ -143,7 +143,7 @@ export const AgentActivityFlyout: React.FunctionComponent<{
body={
<FormattedMessage
id="xpack.fleet.agentActivityFlyout.noActivityDescription"
defaultMessage="Activity feed will appear here as agents get enrolled, upgraded, or configured."
defaultMessage="Activity feed will appear here as agents are reassigned, upgraded, or unenrolled."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tweaked description to fix #141186

image

@juliaElastic
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 913.7KB 913.8KB +122.0B

History

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

cc @juliaElastic

@juliaElastic juliaElastic merged commit 3433f5d into elastic:main Sep 22, 2022
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 22, 2022
* fix for force unenroll

* fixed tests

* fixed checks, solve for one more edge case: only updating unenroll actions that do not have results yet

* added more tests

* added try catch

* updated description on flyout

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 3433f5d)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.5

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 Sep 22, 2022
* fix for force unenroll

* fixed tests

* fixed checks, solve for one more edge case: only updating unenroll actions that do not have results yet

* added more tests

* added try catch

* updated description on flyout

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 3433f5d)

Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.5.0 v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Unenroll action is stuck in progress after force unenroll agent
6 participants