rancher: [BUG] New cattle impersonation token for every call to downstream cluster
Rancher Server Setup
- Rancher version: 2.7.9 (upgraded from 2.6.13 which was in the past upgraded from 2.6.8 and 2.6.3)
- Installation option (Docker install/Helm Chart):
- If Helm Chart, Kubernetes Cluster and version (RKE1, RKE2, k3s, EKS, etc):
- Helm chart: v2.7.9
- Using EKS clusters imported as generic cluster
- Proxy/Cert Details:
- Managed by cert-manager (private CA)
Information about the Cluster
- Kubernetes version: 1.25 (Rancher server on K8s v1.24)
- Cluster Type Downstream
- Downstream, generic imported cluster.
User Information
- What is the role of the user logged in? Admin
Describe the bug Rancher server on our main cluster seems to be running fine. Rancher-agent on the client seems to be running fine. However for every call made through kubectl a new token secret is created for the service account
To Reproduce
- Upgrade from Rancher 2.6.13 to 2.7.9.
Result
For every Kubectl call made through Rancher a new token is created logs from Rancher server:
[INFO] EnsureSecretForServiceAccount: waiting for secret [cattle-impersonation-u-******-token-9tq84] to be populated with token
This repeates for every call. Sometimes calls finish other times they throw an error message about not being able to locate the secret for the service account needed.
$ k get po --kubeconfig <rancher-kubeconfig>.yaml
No resources found in default namespace.
$ k get po --kubeconfig <rancher-kubeconfig>.yaml
No resources found in default namespace.
$ k get po --kubeconfig <rancher-kubeconfig>.yaml
Error from server (InternalError): an error on the server ("unable to create impersonator account: error setting up impersonation for user u-********: failed to get secret for service account: cattle-impersonation-system/cattle-impersonation-u-******, error: timed out waiting for the condition") has prevented the request from succeeding (get pods)
If we look at the secrets on the downstream cluster we see a new secret was created for each call.
This results in our teams losing connection to the cluster and being unable to commit changes succesfully.
Expected Result To re-use the same token after creation
Additional context We have upgraded from v2.6.13 to v2.7.9, since then this error occured. Seems like the message we see comes from here: https://github.com/rancher/rancher/commit/8f4d60c2228de4672a469d07213778ce53df9433#diff-8a853a257f4c9e8e5812b706a4f6a56eaa32ff67e57f9ac5ac4f78f1e1659f04R65
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 20 (3 by maintainers)
As you can see on the output, there is ~380000 secrets on this downstream cluster ETCD.
We had similar problem. During upgrade rancher from
v2.7.6tov2.7.9, incattle-impersonation-systemnamespace, thousands of secrets (cattle-impersonation-user****) were generated until server crashed due to OOM killed.In logs we also found
[INFO] EnsureSecretForServiceAccount: waiting for secret [cattle-impersonation-u-xxxxxx] to be populated with tokenAdditional information:
I wonder if this issue is related. We just experienced this for our Portworx service account. Deleting all of the tokens for that account brought the cluster back to life and stopping the Portworx pods caused the tokens to stop being generated. This randomly started on 5/31 but we can’t determine any clear cause.
Hi, you can do this directly in etcd, this takes 2 seconds.
Note: It got better after upgrading to version 2.8.0, but I still see more secrets than before
Inside pod, execute
I checked multiple clusters in different versions and each of them has duplicated secrets for one particular user. So it is probably long lasting bug. Update of cluster makes it significantly worse. tens thousands of secrets and then OOM of API server or/and etcd.
Strange thing is that
kubectl delete secrets -n cattle-impersonation-system --allhelps and it settles down after that. Still increasing but very slowly.btw: We use AD for user auth. No idea if it is connected with this bug or not.
Same here, i’ve upgraded the upstream cluster from 2.7.4 to 2.7.9 and downstream clusters started to create impersonation secrets wich huge increased the ETCD size, i suspect that when upstream cluster is requesting a new impersonation token secret it is getting timed out and the request restart the secret creation, i found many of this on log:
E0108 21:10:08.585173 1 machineset_controller.go:890] “Unable to retrieve Node status” err="failed to create cluster accessor: error creating dynamic rest mapper for remote cluster "ns-xpto": an error on the server ("unable to create impersonator account: error getting service account token: error getting secret: error ensuring secret for service account [cattle-impersonation-system:cattle-impersonation-u-brlgzerlri]: timed out waiting for the condition")…
This worsened after our infrastructure became slow.
What I observed was an attempt to create a token, with a timeout being reached, and yet, that token was still created.
This led to a looping of token creation, which might be a bug.
Only on downstream-cluster
I try to describe it more precisely what we did and how we ‘fixed’ it:
v2.7.9(which was succeed) secrets were generated in huge amounts until OOM killer occurred.cattle-impersonation-systemnamespaceAfter this action cluster was up and running and looks stable.
We tried upgrade 3 clusters and all of this had same problem