{"record":{"id":"e2d10786a5abbd9b","repo":"rancher/rancher","slug":"no-cluster-registration-token-found","errorCode":null,"errorMessage":"no cluster registration token found","messagePattern":"no cluster registration token found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/capr/planner/agent.go","lineNumber":24,"sourceCode":"\n\trkev1 \"github.com/rancher/rancher/pkg/apis/rke.cattle.io/v1\"\n\tcrt \"github.com/rancher/rancher/pkg/controllers/dashboard/clusterregistrationtoken\"\n\t\"github.com/rancher/rancher/pkg/systemtemplate\"\n)\n\n// generateClusterAgentManifest generates a cluster agent manifest\nfunc (p *Planner) generateClusterAgentManifest(controlPlane *rkev1.RKEControlPlane, entry *planEntry) ([]byte, error) {\n\tif controlPlane.Spec.ManagementClusterName == \"local\" {\n\t\treturn nil, nil\n\t}\n\n\ttokens, err := p.clusterRegistrationTokenCache.GetByIndex(ClusterRegToken, controlPlane.Spec.ManagementClusterName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(tokens) == 0 {\n\t\treturn nil, fmt.Errorf(\"no cluster registration token found\")\n\t}\n\n\tsort.Slice(tokens, func(i, j int) bool {\n\t\treturn tokens[i].Name < tokens[j].Name\n\t})\n\n\tmgmtCluster, err := p.managementClusters.Get(controlPlane.Spec.ManagementClusterName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttaints, err := getTaints(entry, controlPlane)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttoken, err := crt.GetTokenFromSecret(p.secretCache, tokens[0])\n\tif err != nil {","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/rancher/rancher/blob/932558d4e68565aff2d2f36e89ec4a391b06e7c5/pkg/capr/planner/agent.go#L6-L42","documentation":"generateClusterAgentManifest builds the manifest that deploys cattle-cluster-agent onto nodes of a downstream cluster. For any management cluster other than the built-in 'local' one it looks up ClusterRegistrationTokens via the ClusterRegToken index on Spec.ManagementClusterName; an empty result means Rancher has not yet created (or has deleted) the registration token for that cluster, so no token can be embedded in the agent manifest.","triggerScenarios":"The planner renders the plan for a machine immediately after cluster creation, before rancher's clusterregistrationtoken controller has created the token object; the token was manually deleted; controller/index not yet synced after a Rancher restart.","commonSituations":"Race between planner and dashboard controllers on brand-new or imported clusters; downstream agent deployment failing on the first plan attempts; Rancher upgrades where informer caches start empty.","solutions":["Wait for reconciliation: the planner requeues and succeeds once the token exists","Confirm the token object exists: kubectl get clusterregistrationtokens.management.cattle.io -A | grep <cluster-name>","If missing, inspect rancher's clusterregistrationtoken controller logs and restart the rancher deployment to re-trigger creation","For imported clusters, re-run the agent-installation flow to regenerate registration state"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight: confirm a registration token exists before expecting agent manifests\ntokens, err := crtCache.GetByIndex(ClusterRegToken, mgmtClusterName)\nif err != nil {\n\treturn err\n}\nif len(tokens) == 0 {\n\treturn fmt.Errorf(\"no clusterregistrationtoken for %s yet; requeue\", mgmtClusterName)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Expect first plan renders of a new cluster to race the clusterregistrationtoken controller; rely on planner requeue","Verify clusterregistrationtokens exist before scaling downstream nodes","Do not manually delete ClusterRegistrationToken objects","After Rancher upgrades, allow informer caches to sync before provisioning"],"tags":["cluster-agent","registration-token","timing","rancher"],"backgroundTag":null,"analyzedSha":"932558d4e68565aff2d2f36e89ec4a391b06e7c5","analyzedAt":"2026-08-16T04:37:02.125Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}