{"record":{"id":"3290a7004fa4cea7","repo":"cilium/cilium","slug":"clusterid-d-is-already-used","errorCode":null,"errorMessage":"clusterID %d is already used","messagePattern":"clusterID (.+?) is already used","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/clustermesh/common/idsmgr.go","lineNumber":47,"sourceCode":"\treturn &clusterIDsManager{\n\t\tlocalClusterID: info.ID,\n\t\tusedIDs:        sets.New[uint32](),\n\t}\n}\n\nfunc (m *clusterIDsManager) ReserveClusterID(clusterID uint32) error {\n\tif clusterID == types.ClusterIDUnset {\n\t\treturn fmt.Errorf(\"clusterID %d is reserved\", clusterID)\n\t}\n\tif clusterID == m.localClusterID {\n\t\treturn fmt.Errorf(\"clusterID %d is assigned to the local cluster\", clusterID)\n\t}\n\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\n\tif m.usedIDs.Has(clusterID) {\n\t\treturn fmt.Errorf(\"clusterID %d is already used\", clusterID)\n\t}\n\tm.usedIDs.Insert(clusterID)\n\treturn nil\n}\n\nfunc (m *clusterIDsManager) ReleaseClusterID(clusterID uint32) {\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\n\tm.usedIDs.Delete(clusterID)\n}\n","sourceCodeStart":29,"sourceCodeEnd":59,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/clustermesh/common/idsmgr.go#L29-L59","documentation":"clusterIDsManager.ReserveClusterID in pkg/clustermesh/common/idsmgr.go:47 rejects a clusterID already held by another remote cluster (m.usedIDs, guarded by mutex). IDs must be globally unique across the mesh; the manager throws this when a second remote connection tries to claim an ID that is currently in use.","triggerScenarios":"Calling ReserveClusterID(id) twice for different clusters without ReleaseClusterID(id) between them, or connecting two remote clusters both configured with the same cluster-id.","commonSituations":"Two remote clusters misconfigured with the same --cluster-id; leaking reservations after a failed/disconnected remote cluster (missing ReleaseClusterID) so the ID stays 'used'; rapid reconnect loops reusing an ID.","solutions":["Assign a unique cluster ID per remote cluster; fix the duplicate --cluster-id on the offending cluster.","Ensure ReleaseClusterID is called when a remote cluster is disconnected/removed so IDs are freed.","If a stale reservation persists after a crash, restart the component to reset the manager, then reconnect with correct IDs."],"exampleFix":"// before\nm.ReserveClusterID(2) // cluster B\nm.ReserveClusterID(2) // cluster C — error\n// after\nm.ReserveClusterID(2) // cluster B\nm.ReserveClusterID(3) // cluster C — unique ID","handlingStrategy":"try-catch","validationCode":"if inUse, _ := mgr.reserved(id); inUse {\n\treturn fmt.Errorf(\"cluster ID %d already reserved by another remote cluster\", id)\n}\nif err := mgr.ReserveClusterID(id); err != nil { return err }","typeGuard":null,"tryCatchPattern":"if err := mgr.ReserveClusterID(id); err != nil {\n\tif strings.Contains(err.Error(), \"already used\") {\n\t\tlog.Errorf(\"cluster ID %d taken; call ReleaseClusterID on removal or assign a new ID\", id)\n\t}\n}","preventionTips":["Always pair ReserveClusterID with ReleaseClusterID when a remote cluster disconnects.","Enforce unique cluster IDs via a fleet-level allocation policy or controller.","On startup, reconcile reserved IDs against the actual set of connected remote clusters."],"tags":["cluster-id","conflict","uniqueness","clustermesh","go"],"backgroundTag":"invalid-cluster-id","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}