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] Add a reset API #118214

Closed
1 task
Tracked by #111194
jen-huang opened this issue Nov 10, 2021 · 8 comments
Closed
1 task
Tracked by #111194

[Fleet] Add a reset API #118214

jen-huang opened this issue Nov 10, 2021 · 8 comments
Labels
enhancement New value added to drive a business result Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@jen-huang
Copy link
Contributor

jen-huang commented Nov 10, 2021

  • Add a reset API
    • This can be used to help customers who upgraded from experimental and beta versions of Fleet and have corrupt data due to unsupported migrations.
    • Also helpful for when something went wrong and a user just wants to start over.
    • Deletes all agent policies and package policies, enrollment keys, etc.
    • Allows user to run setup again from a clean state
    • Examples:
@jen-huang jen-huang changed the title Add a reset API [Fleet] Add a reset API Nov 10, 2021
@botelastic botelastic bot added the needs-team Issues missing a team label label Nov 10, 2021
@jen-huang jen-huang added enhancement New value added to drive a business result and removed needs-team Issues missing a team label labels Nov 10, 2021
@botelastic botelastic bot added the needs-team Issues missing a team label label Nov 10, 2021
@jen-huang jen-huang added Team:Fleet Team label for Observability Data Collection Fleet team and removed needs-team Issues missing a team label labels Nov 10, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@joshdover
Copy link
Contributor

joshdover commented Dec 9, 2021

It'd be nice if this API provided two modes:

  • Reset preconfiguration mode
    • This would only delete & recreate the objects that are configured in the kibana.yml and not touch any other agent policies or package policies that were created by the user.
    • Agents enrolled in any of the policies that will be deleted will have to be unenrolled, else the policy revisions will get out of sync.
  • Full reset mode
    • This would destructively delete everything and run Fleet setup again.
    • Running this accidentally should be very hard. For example, we could require a verbose query parameter like ?iUnderstandThisDeletesEverything=true

Open questions:

  • How will Fleet Server behave if a policy is deleted and the re-created with the same policy ID? If it needs to be restarted, how should we communicate this?
  • Can we retain any package policies the user added to the agent policies that we re-create? (in the first mode)
  • Should these endpoints automatically run Fleet setup after the deletions?
  • Do we need to uninstall packages or can we just force reinstall them?
    • I lean towards uninstall to force a clean state before installing

@nchaulet
Copy link
Member

nchaulet commented Dec 21, 2021

I think it will make sense to have a reset API for 7.x. This will really help as in most of our SDH we provide information to reset default policies.

One good starting point and the less risky option will be to implement a reset preconfigured policy, something like this:

POST /api/fleet/reset-preconfigured-agent-policies

That API will delete all the saved object related to the default policies:

  • Package policies
  • Default agent policies, we should try to force unenroll agent here

Then we should clean all .fleet-* internal for these policies

  • .fleet-enrollment-tokens we should try to invalidate the related API key when deleting a document from here.
  • .fleet-policies

Then this should call the setup to restore the preconfigured policies.

@joshdover
Copy link
Contributor

joshdover commented Dec 22, 2021

++ this keeps coming up in SDHs. I'm +1 on adding the very specific API @nchaulet mentioned above only to 7.x for the time being to help with those cases and only consider adding in 8.x if we still have not solved the problem fully (which I believe we have). Once we align on a proposal, let's open a separate issue and schedule this for early January.

We can consider a more generic reset API in the future as needed.

@joshdover
Copy link
Contributor

@kpollich any feedback on the proposal in #118214 (comment) based on your experience in the SDHs?

@kpollich
Copy link
Member

@kpollich any feedback on the proposal in #118214 (comment) based on your experience in the SDHs?

100% on board with @nchaulet's proposal for a very specific API. We run through this exact process when recreating the cloud policy on a consistent basis in SDH's.

@joshdover
Copy link
Contributor

Thanks for taking a look, I'll open a separate issue and add to our board.

@joshdover
Copy link
Contributor

Closing this as we haven't had a need for this since #121887 was implemented.

@joshdover joshdover closed this as not planned Won't fix, can't repro, duplicate, stale Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

No branches or pull requests

5 participants