{"record":{"id":"27079203af96efdd","repo":"cilium/cilium","slug":"unexpected-cluster-name-got-s-expected-s-270792","errorCode":null,"errorMessage":"unexpected cluster name: got %s, expected %s","messagePattern":"unexpected cluster name: got (.+?), expected (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/identity/cache/allocator.go","lineNumber":1069,"sourceCode":"\t\t\treturn nil\n\t\t}\n\n\t\tgi, ok := ak.(*key.GlobalIdentity)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unsupported key type %T\", ak)\n\t\t}\n\n\t\tvar found bool\n\t\tfor _, lbl := range gi.LabelArray {\n\t\t\tif lbl.Key != api.PolicyLabelCluster {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tswitch {\n\t\t\tcase lbl.Source != labels.LabelSourceK8s:\n\t\t\t\treturn fmt.Errorf(\"unexpected source for cluster label: got %s, expected %s\", lbl.Source, labels.LabelSourceK8s)\n\t\t\tcase lbl.Value != clusterName:\n\t\t\t\treturn fmt.Errorf(\"unexpected cluster name: got %s, expected %s\", lbl.Value, clusterName)\n\t\t\tdefault:\n\t\t\t\tfound = true\n\t\t\t}\n\t\t}\n\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"could not find expected label %s\", api.PolicyLabelCluster)\n\t\t}\n\n\t\treturn nil\n\t}\n}\n\nfunc ScriptCmds(a *CachingIdentityAllocator) map[string]script.Cmd {\n\treturn map[string]script.Cmd{\n\t\t\"identity/list\": script.Command(\n\t\t\tscript.CmdUsage{\n\t\t\t\tSummary: \"List all identities in the allocator\",","sourceCodeStart":1051,"sourceCodeEnd":1087,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/identity/cache/allocator.go#L1051-L1087","documentation":"clusterNameValidator checks that the value of the cilium.io/cluster label equals the locally configured cluster name. When the label exists but its value differs, this error is returned. It prevents an agent from validating identities belonging to a different cluster.","triggerScenarios":"An identity carries PolicyLabelCluster with a value that does not match the agent's --cluster-name, typically observed during kvstore sync when entries from another cluster are visible.","commonSituations":"Two clusters sharing an etcd with identical or misconfigured --cluster-name values; renaming a cluster without purging old identities; copying kvstore data between environments.","solutions":["Set --cluster-name on the agent to match the cluster labels of the identities you intend to share.","Purge stale identities from the old cluster name in the kvstore.","Verify each clustermesh peer uses a unique cluster-name."],"exampleFix":"// before\ncilium-agent --cluster-name=west --cluster-id=1  # identities labeled cluster=prod\n// after\ncilium-agent --cluster-name=prod --cluster-id=1","handlingStrategy":"validation","validationCode":"for _, lbl := range gi.LabelArray {\n    if lbl.Key == api.PolicyLabelCluster && lbl.Value != clusterName {\n        return fmt.Errorf(\"identity from cluster %q, expected %q\", lbl.Value, clusterName)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"unexpected cluster name\") {\n    log.WithError(err).Errorf(\"identity belongs to a different cluster; check --cluster-name\")\n}","preventionTips":["Use a unique --cluster-name per clustermesh peer.","Never reuse a cluster name for a different cluster without purging the kvstore.","Validate cluster-name in deployment tooling before rollout."],"tags":["cilium","clustermesh","labels"],"backgroundTag":"cluster-name-mismatch","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}