{"record":{"id":"9a3ad1a21ee45583","repo":"hashicorp/nomad","slug":"allocation-missing-s","errorCode":null,"errorMessage":"allocation missing: %s","messagePattern":"allocation missing: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/csi.go","lineNumber":625,"sourceCode":"\tif claim.State == CSIVolumeClaimStateTaken {\n\t\tswitch claim.Mode {\n\t\tcase CSIVolumeClaimRead:\n\t\t\treturn v.claimRead(claim, alloc)\n\t\tcase CSIVolumeClaimWrite:\n\t\t\treturn v.claimWrite(claim, alloc)\n\t\t}\n\t}\n\t// either GC or a Unpublish checkpoint\n\treturn v.claimRelease(claim)\n}\n\n// claimRead marks an allocation as using a volume read-only\nfunc (v *CSIVolume) claimRead(claim *CSIVolumeClaim, alloc *Allocation) error {\n\tif _, ok := v.ReadAllocs[claim.AllocationID]; ok {\n\t\treturn nil\n\t}\n\tif alloc == nil {\n\t\treturn fmt.Errorf(\"allocation missing: %s\", claim.AllocationID)\n\t}\n\n\tif !v.ReadSchedulable() {\n\t\treturn ErrCSIVolumeUnschedulable\n\t}\n\n\tif !v.HasFreeReadClaims() {\n\t\treturn ErrCSIVolumeMaxClaims\n\t}\n\n\t// Allocations are copy on write, so we want to keep the id but don't need the\n\t// pointer. We'll get it from the db in denormalize.\n\tv.ReadAllocs[claim.AllocationID] = nil\n\tdelete(v.WriteAllocs, claim.AllocationID)\n\n\tv.ReadClaims[claim.AllocationID] = claim\n\tdelete(v.WriteClaims, claim.AllocationID)\n\tdelete(v.PastClaims, claim.AllocationID)","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/csi.go#L607-L643","documentation":"This error is returned by CSIVolume.claimRead when a read claim references an AllocationID that has no corresponding Allocation object. Nomad requires the actual Allocation to validate the claim against volume scheduling state (ReadAllocs, ReadSchedulable), so a missing allocation aborts the claim. It indicates the claim's allocID does not exist in the state store snapshot being used.","triggerScenarios":"Calling CSIVolume.Claim (via volume claim RPC) with a CSIVolumeClaim whose AllocationID was deleted (alloc garbage-collected, node lost, job stopped) before the claim is processed, or passing an alloc ID that never existed / was typographically wrong.","commonSituations":"A volume claim races with allocation deregistration (e.g. job stopped while claim evaluation in flight); state store restored from a backup where the alloc was pruned; a client or tooling submitting a claim with a mistyped alloc ID.","solutions":["Re-submit the volume claim with a valid, currently-running allocation ID (nomad alloc status <id> to confirm it exists).","If the alloc was legitimately stopped, stop or delete the stale claim (nomad volume detach <vol> <allocID>) and re-claim from a live alloc.","Check for a race between claim and job stop; retry the claim after the evaluation completes so the alloc snapshot is consistent.","Verify the state store is intact (nomad operator raft list-peers / snapshot restore) if many allocs are missing."],"exampleFix":"// before\nclaim := &structs.CSIVolumeClaim{AllocationID: \"e62b3c58-4fae-4c1d-8873-bb03a30a4d32\"} // alloc already stopped\nvol.Claim(structs.CSIVolumeClaimWrite, claim, nil)\n// after\nalloc, err := state.AllocByID(nil, claimID)\nif err != nil || alloc == nil {\n    return fmt.Errorf(\"alloc %s no longer exists; pick a running alloc\", claimID)\n}\nclaim := &structs.CSIVolumeClaim{AllocationID: claimID}\nvol.Claim(structs.CSIVolumeClaimWrite, claim, alloc)","handlingStrategy":"validation","validationCode":"alloc, err := state.AllocByID(nil, claim.AllocationID)\nif err != nil {\n    return err\n}\nif alloc == nil {\n    return fmt.Errorf(\"alloc %s does not exist; cannot claim volume %s\", claim.AllocationID, vol.ID)\n}\nerr = vol.Claim(structs.CSIVolumeClaimRead, claim, alloc)","typeGuard":"func allocExists(alloc *structs.Allocation) bool { return alloc != nil && alloc.ID != \"\" }","tryCatchPattern":"err := vol.Claim(structs.CSIVolumeClaimRead, claim, alloc)\nif err != nil {\n    if strings.Contains(err.Error(), \"allocation missing\") {\n        // alloc was GC'd; drop the stale claim and re-claim from a live alloc\n        return retryWithLiveAlloc(claim.VolumeID, jobID)\n    }\n    return err\n}","preventionTips":["Always resolve the Allocation from the state store and pass it into Claim, never nil.","Detach volume claims when stopping jobs before alloc GC runs.","Use nomad volume status <vol> to see which claims reference dead allocs and prune them.","Retry claims after evaluation completes to avoid racing alloc deregistration."],"tags":["nomad","csi","volume-claim","missing-allocation"],"backgroundTag":"missing-allocation-claim","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"}