rancher: helm upgrade/delete intermittently fails with errors like "unable to create impersonator account: error setting up impersonation for user u-xxxxx..Operation cannot be fulfilled on clusterroles.rbac.authorization.k8s.io \"cattle-impersonation-u-8j72f\": the object has been modified; please apply your changes to the latest version and try again."
Rancher Server Setup
- Rancher version: 2.6.0
- Installation option (Docker install/Helm Chart): ?
- Proxy/Cert Details: ?
Information about the Cluster
- Kubernetes version: ?
- Cluster Type (Local/Downstream): Downstream
- If downstream, what type of cluster? (Custom/Imported or specify provider for Hosted/Infrastructure Provider): ?
Describe the bug
Running helm upgrade
/ helm uninstall
for an unknown application intermittently fails with errors like this:
error: unable to recognize "/tmp/kubectl_replace_486731274/resource.stdin": an error on the server ("unable to create impersonator account: error setting up impersonation for user u-8j72f: Operation cannot be fulfilled on clusterroles.rbac.authorization.k8s.io \"cattle-impersonation-u-8j72f\": the object has been modified; please apply your changes to the latest version and try again") has prevented the request from succeeding
Error: uninstall: Release not loaded: katana-api-dev: query: failed to query with labels: an error on the server ("unable to create impersonator account: error setting up impersonation for user u-8j72f: Operation cannot be fulfilled on clusterroles.rbac.authorization.k8s.io \"cattle-impersonation-u-8j72f\": the object has been modified; please apply your changes to the latest version and try again") has prevented the request from succeeding (get secrets)
Additional context
Created from the following comment: https://github.com/rancher/rancher/issues/34187#issuecomment-914575796
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 29 (8 by maintainers)
Thanks for all the hints, @ctrox and @andrew-landsverk-win, I was able to reproduce it and I will have a patch incoming soon.
@anupama2501 here’s what I did to reproduce:
After the first initial errors it will go away, you can remove and re-add the user to the cluster to see the errors again.
I haven’t reproduced @ctrox’s exact issue with the reordering of groups but I imagine it should be doable by setting up an auth provider where the user has multiple groups coming from the auth provider, or doing what @ctrox did and switching from one auth provider to another.
Verified on the v2.6-head 223ec88
Upgrade scenario Followed the same steps as above reproduction steps to create rancher server on v2.6.0 Upgraded the rancher server to v2.6-head version As the auth user, tried running the command
for i in seq 1 10 ; do echo kubectl get pod -A --kubeconfig rkeimport.yaml; done | xargs -I {} -P 10 bash -c "{}"
Verified no errors were seenNew user on an upgraded setup Created a new user Added the user as a cluster member and ran the kubectl command Changed the permission from cluster member to cluster owner tried running the command and no errors were seen
On a fresh install of v2.6-head Created a new user as an admin, Added the user to the cluster as cluster member, and then later changed to cluster owner Ran the kubectl command, no errors were seen
Able to reproduce the issue on v2.6.0
import an existing cluster Generic type
option to create a cluster.curl --insecure -sfL https://<redacted> | kubectl apply -f -
against the cluster created in step2for i in
seq 1 10; do echo kubectl get pod -A --kubeconfig rkeimport.yaml; done | xargs -I {} -P 10 bash -c "{}"
Not sure if that’s exactly the same issue, but it may be:
I just upgraded a Rancher cluster from 2.5.9 to 2.6.0. It now fails to upgrade the agent in the downstream cluster.
No keycloak is in use, but we use FreeIPA authentication, if that matters.
Just to add some more information, I added a
logrus.Info(cmp.Diff(role.Rules, rules))
in this block to see what is constantly changing in thatClusterRole
. This is the diff I got over and over, one update call would empty out theResourceNames
while the next one would add them back again.This is a local user, so nothing related to Keycloak.
So out of curiosity I scaled Rancher to a single replica (from 3) and now I see way less of these diffs and so far I did not see the “unable to create impersonator account” error again.
Interesting, so no keycloak auth provider. In the meantime I have created a new local user and while I still see the error
unable to create impersonator account
appear from time to time it is way less frequent than with the keycloak user. I can see that theclusterRole
is still frequently updated by rancher so I guess there is some other bug in that update logic that causes this.@andrew-landsverk-win , this should help: https://rancher.com/docs/rancher/v2.6/en/troubleshooting/logging/