{"record":{"id":"861918773ae8b9f0","repo":"hashicorp/nomad","slug":"volume-not-found-s-861918","errorCode":null,"errorMessage":"volume not found: %s","messagePattern":"volume not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":2879,"sourceCode":"\t\treturn nil, fmt.Errorf(\"volume lookup failed: %v\", err)\n\t}\n\n\tws.Add(iter.WatchCh())\n\n\treturn iter, nil\n}\n\n// CSIVolumeClaim updates the volume's claim count and allocation list\nfunc (s *StateStore) CSIVolumeClaim(index uint64, now int64, namespace, id string, claim *structs.CSIVolumeClaim) error {\n\ttxn := s.db.WriteTxnMsgT(structs.CSIVolumeClaimRequestType, index)\n\tdefer txn.Abort()\n\n\trow, err := txn.First(TableCSIVolumes, \"id\", namespace, id)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"volume lookup failed: %s: %v\", id, err)\n\t}\n\tif row == nil {\n\t\treturn fmt.Errorf(\"volume not found: %s\", id)\n\t}\n\n\torig, ok := row.(*structs.CSIVolume)\n\tif !ok {\n\t\treturn fmt.Errorf(\"volume row conversion error\")\n\t}\n\n\tvar alloc *structs.Allocation\n\tif claim.State == structs.CSIVolumeClaimStateTaken {\n\t\talloc, err = s.allocByIDImpl(txn, nil, claim.AllocationID)\n\t\tif err != nil {\n\t\t\ts.logger.Error(\"AllocByID failed\", \"error\", err)\n\t\t\treturn fmt.Errorf(structs.ErrUnknownAllocationPrefix)\n\t\t}\n\t\tif alloc == nil {\n\t\t\ts.logger.Error(\"AllocByID failed to find alloc\", \"alloc_id\", claim.AllocationID)\n\t\t}\n\t}","sourceCodeStart":2861,"sourceCodeEnd":2897,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L2861-L2897","documentation":"Returned by StateStore.CSIVolumeClaim when the volume row for the given namespace+id simply does not exist (txn.First returned nil). It means a claim (mount/unmount) is being requested against a CSI volume that was deregistered or never registered in this cluster. The %s is the requested volume ID.","triggerScenarios":"CSIVolumeClaim called with an id/namespace combination absent from the state store — e.g. the volume was deregistered between the job submission and the alloc claiming it, or the namespace in the claim does not match where the volume lives.","commonSituations":"Volume deleted via nomad volume delete while jobs still reference it; job spec references a volume registered in a different namespace; ACL/namespace mismatch in multitenant clusters; stale job referencing volumes from a purged cluster.","solutions":["Run nomad volume status to confirm the volume exists in the expected namespace","Re-register the volume (nomad volume register or dynamic creation) if it was deleted","Fix the job's volume block: correct id and namespace to match an existing volume","Stop/redo allocations stuck referencing the deleted volume"],"exampleFix":"// before: job references a deregistered volume\nvolume \"missing-vol\" { type = \"csi\" source = \"old-ebs-vol\" }\n// after: register the volume first, then reference it\n# nomad volume register -namespace=default ./ebs-vol.hcl\nvolume \"missing-vol\" { type = \"csi\" source = \"ebs-vol\" }","handlingStrategy":"validation","validationCode":"// guard before claiming\nvol, _, err := api.CSIVolumesByID(nil, namespace, volumeID)\nif err != nil {\n    return err\n}\nif vol == nil {\n    return fmt.Errorf(\"volume %q not found in namespace %q; register it first\", volumeID, namespace)\n}","typeGuard":"func volumeExists(vol *api.CSIVolume, err error) bool { return err == nil && vol != nil }","tryCatchPattern":"err := api.CSIVolumeClaim(&structs.CSIVolumeClaimRequest{VolumeID: id, Namespace: ns})\nif err != nil && strings.Contains(err.Error(), \"volume not found\") {\n    // volume deregistered or wrong namespace: re-register or fix the job spec\n}","preventionTips":["Reference CSI volumes with correct id AND namespace in job specs","Check nomad volume status before deleting volumes still used by jobs","Re-register volumes after cluster rebuilds before scheduling workloads","Use ACL policies/namespaces consistently in multitenant clusters"],"tags":["csi","volume","claim","not-found","nomad"],"backgroundTag":"resource-not-found","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}