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] Unable to reassign agents to another policy when current policy is deleted #90625

Closed
jen-huang opened this issue Feb 8, 2021 · 2 comments · Fixed by #94311
Closed
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@jen-huang
Copy link
Contributor

jen-huang commented Feb 8, 2021

Originally posted by @patrykkopycinski in #89372 (comment)

I've found one more issue I think, I've had a case where my agents were assigned to the policy that was removed and when I tried to reassign agents to the new policy I was getting an error that saved object with old policy id doesn't exist
https://github.com/elastic/kibana/pull/89372/files#diff-11bcc5bb1eaf5ddae753f9ee690233bef988d13ddbf6baf71c4c8edd0d6a4933L186-L189

I've had to wrap this line into try/catch block to make sure that saved object error is not being thrown

let agentPolicySO;

try {
  agentPolicySO = await soClient.get<AgentPolicySOAttributes>(SAVED_OBJECT_TYPE, id);
  // eslint-disable-next-line no-empty
} catch (e) {}

if (!agentPolicySO) {
  return null;
}
@jen-huang jen-huang added bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team labels Feb 8, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@afgomez
Copy link
Contributor

afgomez commented Mar 10, 2021

I cannot reproduce the issue as described, since the UI doesn't allow to remove a policy if it has an agent assigned. However I manged to get a similar error with the following steps

  1. Create a policy
  2. Enroll an agent, and assign the created policy
  3. Unenroll the agent
  4. Delete the policy: get the error on fleet/agent_policies/delete

Screenshot 2021-03-10 at 12 52 40

I'm going to tackle that scenario

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 Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants