{"record":{"id":"e3029e9369a961b4","repo":"hashicorp/nomad","slug":"volume-q-cannot-be-expanded-while-in-use-v","errorCode":null,"errorMessage":"volume %q cannot be expanded while in use: %v","messagePattern":"volume %q cannot be expanded while in use: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugins/csi/client.go","lineNumber":945,"sourceCode":"\t}\n\tif err := c.ensureConnected(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\n\texReq := req.ToCSIRepresentation()\n\tresp, err := c.nodeClient.NodeExpandVolume(ctx, exReq, opts...)\n\tif err != nil {\n\t\tcode := status.Code(err)\n\t\tswitch code {\n\t\tcase codes.InvalidArgument:\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"requested capabilities not compatible with volume %q: %v\",\n\t\t\t\treq.ExternalVolumeID, err)\n\t\tcase codes.NotFound:\n\t\t\treturn nil, fmt.Errorf(\"%w: volume %q could not be found: %v\",\n\t\t\t\tstructs.ErrCSIClientRPCIgnorable, req.ExternalVolumeID, err)\n\t\tcase codes.FailedPrecondition:\n\t\t\treturn nil, fmt.Errorf(\"volume %q cannot be expanded while in use: %v\", req.ExternalVolumeID, err)\n\t\tcase codes.OutOfRange:\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"unsupported capacity_range for volume %q: %v\", req.ExternalVolumeID, err)\n\t\tcase codes.Internal:\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"node plugin returned an internal error, check the plugin allocation logs for more information: %v\", err)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"node plugin returned an error: %v\", err)\n\t\t}\n\t}\n\n\treturn &NodeExpandVolumeResponse{resp.GetCapacityBytes()}, nil\n}\n","sourceCodeStart":927,"sourceCodeEnd":959,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/plugins/csi/client.go#L927-L959","documentation":"Nomad's CSI client wraps gRPC status errors returned by the CSI node plugin during NodeExpandVolume. When the plugin replies with codes.FailedPrecondition, the client converts it to this message: the volume cannot be expanded because it is currently in use (mounted/attached). It signals a precondition violation of the CSI spec rather than a transient failure.","triggerScenarios":"Calling NodeExpandVolume on a volume whose node plugin reports FailedPrecondition — typically because the volume is attached/mounted by a running allocation at expand time.","commonSituations":"Expanding a Nomad CSI volume while an allocation still has it mounted; online expansion unsupported by the storage provider; forgetting to stop the job (or reschedule it off the node) before resizing.","solutions":["Stop or migrate the allocations using the volume (drain the node or stop the job) so the volume is detached, then retry NodeExpandVolume","Verify the storage provider/plugin supports online (in-use) volume expansion; if so, enable it in the plugin config","Check plugin allocation logs for the underlying FailedPrecondition detail to confirm which mount/attachment blocks expansion"],"exampleFix":"// before: expanding while job runs\nnomad volume status my-vol // in use\nnomad node expand ...\n// after: stop consumers first\nnomad job stop fs-job\nnomad system gc\nnomad volume expand my-volume -capacity-bytes=20G","handlingStrategy":"retry","validationCode":"// shell pre-check before expanding\nnomad volume status <volume-id>   # ensure 'Allocations' is empty / volume not claimed\nnomad job inspect <job> | jq '.TaskGroups[].Volumes'","typeGuard":null,"tryCatchPattern":"// Go: retry after detaching\n_, err := client.Nodes().NodeExpandVolume(...)\nif err != nil && strings.Contains(err.Error(), \"cannot be expanded while in use\") {\n    // stop/drain consumers, then retry with backoff\n}","preventionTips":["Check volume claim state (`nomad volume status`) before resizing","Stop or reschedule jobs consuming the volume prior to expansion","Prefer storage providers/plugins that support online volume expansion if zero-downtime resize is required"],"tags":["csi","storage","volume-expansion","grpc"],"backgroundTag":"csi-volume-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"}