-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Update policy fails on duplicate check #149916
Comments
Pinging @elastic/fleet (Team:Fleet) |
Adding some notes from the slack conversation here plus some investigation: The name uniqueness for package policies was introduced with #115212 (related ticket is here). This specific error seems to stem from this code kibana/x-pack/plugins/fleet/server/services/package_policy.ts Lines 508 to 520 in 4baa14a
There is a similar check in kibana/x-pack/plugins/fleet/server/services/package_policy.ts Lines 151 to 163 in 4baa14a
What I noticed is that kibana/x-pack/plugins/fleet/server/services/agent_policy.ts Lines 1091 to 1099 in 4baa14a
service/preconfiguration .
The flag @dgieselaar by chance do you have any preconfigured policy in your setup? I think that this is the only way how we can get into this state, unless I'm missing something. |
Well I think that the issue here can be that the user that creates preconfigured policies might get into this state were there are two policies with the same name. I'm not sure what other problems can stem from this bug, other than being unable to update both the policies as you experienced. @nchaulet could you help on this? |
I do not think there is another issue than being able to update both policies, and I think update updating one of the policy name here is probably the best way to fix that |
@nchaulet @criamico What's concerning me, is that Dario ran into this when APM calls fleet to update a policy here: kibana/x-pack/plugins/apm/server/routes/fleet/api_keys/add_api_keys_to_policies_if_missing.ts Lines 100 to 105 in c2e5381
Can you explain why the error would happen in the above flow? |
We perform name validation in the update method it's possible to skip the verification by adding the Not sure how we got with 2 package policies with the same name in the first place but I think it's possible that happen when:
Does it make sense to you? |
I'm not sure why it happened in Dario's case. It's not my impression that he was editing a policy. Instead I think this just happened due to the background job I mentioned above. I am concerned whether the change in #149944 could cause an extra APM policy to be created every time Kibana restarts. I don't have any suggestions for how to fix it though. Will keep an eye on this and ping you if someone run into this again. |
Should be resolved by #149944 |
I ran into the following error when trying to update a policy:
After listing all the policies it turned out that I indeed had two policies with the same name. This is something that should not be possible according to @criamico, but apparently there's a loophole where two policies can be created or updated to have the same name. I'm not sure how to be honest. I was trying to update an existing policy.
The text was updated successfully, but these errors were encountered: