{"record":{"id":"493a5e95eccea4f3","repo":"hashicorp/nomad","slug":"cannot-update-a-volume-in-use-claimed-by-allocs","errorCode":null,"errorMessage":"cannot update a volume in use: claimed by allocs (%s)","messagePattern":"cannot update a volume in use: claimed by allocs \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/host_volumes.go","lineNumber":184,"sourceCode":"\t\tdefault:\n\t\t}\n\t}\n\n\treturn helper.FlattenMultierror(mErr.ErrorOrNil())\n}\n\n// ValidateUpdate verifies that an update to a volume is safe to make.\nfunc (hv *HostVolume) ValidateUpdate(existing *HostVolume) error {\n\tif existing == nil {\n\t\treturn nil\n\t}\n\n\tvar mErr *multierror.Error\n\tif len(existing.Allocations) > 0 {\n\t\tallocIDs := helper.ConvertSlice(existing.Allocations,\n\t\t\tfunc(a *AllocListStub) string { return a.ID })\n\t\tmErr = multierror.Append(mErr, fmt.Errorf(\n\t\t\t\"cannot update a volume in use: claimed by allocs (%s)\",\n\t\t\tstrings.Join(allocIDs, \", \")))\n\t}\n\n\tif hv.NodeID != \"\" && hv.NodeID != existing.NodeID {\n\t\tmErr = multierror.Append(mErr, errors.New(\"node ID cannot be updated\"))\n\t}\n\tif hv.NodePool != \"\" && hv.NodePool != existing.NodePool {\n\t\tmErr = multierror.Append(mErr, errors.New(\"node pool cannot be updated\"))\n\t}\n\n\tif hv.RequestedCapacityMaxBytes > 0 &&\n\t\thv.RequestedCapacityMaxBytes < existing.CapacityBytes {\n\t\tmErr = multierror.Append(mErr, fmt.Errorf(\n\t\t\t\"capacity_max (%d) cannot be less than existing provisioned capacity (%d)\",\n\t\t\thv.RequestedCapacityMaxBytes, existing.CapacityBytes))\n\t}\n\n\treturn mErr.ErrorOrNil()","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/host_volumes.go#L166-L202","documentation":"ValidateUpdate refuses to modify a host volume that currently has active allocations claiming it. The existing volume's Allocations list is checked; any alloc IDs present mean the volume is in use and updates are blocked to avoid breaking running workloads.","triggerScenarios":"Submitting a host volume update (CSIVolume register or HostVolume update RPC via validateVolumeUpdate) where existing.Allocations is non-empty.","commonSituations":"Trying to change capacity, node, or parameters of a volume while jobs using it are still running; CI pipelines that re-register volumes on every deploy.","solutions":["Stop/drain the jobs whose allocs claim the volume, wait for allocs to be removed, then update the volume","Register a new host volume with a different name and migrate workloads to it","Verify with 'nomad volume status' which allocations hold the volume"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"status, _, err := client.CSIVolumes().Info(volumeID)\nif err == nil && len(status.Allocations) > 0 {\n  return fmt.Errorf(\"volume %s in use by %d allocs; stop jobs first\", volumeID, len(status.Allocations))\n}","typeGuard":null,"tryCatchPattern":"if err := updateVolume(hv); err != nil {\n  if strings.Contains(err.Error(), \"cannot update a volume in use\") {\n    // stop claiming jobs, wait, then retry\n  }\n}","preventionTips":["Check 'nomad volume status <id>' before updating a volume","Automate stop-job-then-update ordering in deployment pipelines","Avoid blanket re-registration of volumes in CI"],"tags":["nomad","validation","host-volume","volume-in-use"],"backgroundTag":"resource-in-use","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"}