{"record":{"id":"6aecfbb6c7f71418","repo":"hashicorp/nomad","slug":"csi-controllerattachvolume-v","errorCode":null,"errorMessage":"CSI.ControllerAttachVolume: %v","messagePattern":"CSI\\.ControllerAttachVolume: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/csi_endpoint.go","lineNumber":116,"sourceCode":"\t}\n\tdefer plugin.Close()\n\n\t// The following block of validation checks should not be reached on a\n\t// real Nomad cluster as all of this data should be validated when registering\n\t// volumes with the cluster. They serve as a defensive check before forwarding\n\t// requests to plugins, and to aid with development.\n\n\tif req.VolumeID == \"\" {\n\t\treturn errors.New(\"CSI.ControllerAttachVolume: VolumeID is required\")\n\t}\n\n\tif req.ClientCSINodeID == \"\" {\n\t\treturn errors.New(\"CSI.ControllerAttachVolume: ClientCSINodeID is required\")\n\t}\n\n\tcsiReq, err := req.ToCSIRequest()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"CSI.ControllerAttachVolume: %v\", err)\n\t}\n\n\t// Submit the request for a volume to the CSI Plugin.\n\tctx, cancelFn := c.requestContext()\n\tdefer cancelFn()\n\t// CSI ControllerPublishVolume errors for timeout, codes.Unavailable and\n\t// codes.ResourceExhausted are retried; all other errors are fatal.\n\tcresp, err := plugin.ControllerPublishVolume(ctx, csiReq,\n\t\tgrpc_retry.WithPerRetryTimeout(CSIPluginRequestTimeout),\n\t\tgrpc_retry.WithMax(3),\n\t\tgrpc_retry.WithBackoff(grpc_retry.BackoffExponential(100*time.Millisecond)))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"CSI.ControllerAttachVolume: %v\", err)\n\t}\n\n\tresp.PublishContext = cresp.PublishContext\n\treturn nil\n}","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/csi_endpoint.go#L98-L134","documentation":"ControllerAttachVolume returns this when req.ToCSIRequest() cannot build a valid CSI ControllerPublishVolume request, or (per the source block) when required fields like VolumeID or ClientCSINodeID are empty — these should have been validated server-side before reaching the client.","triggerScenarios":"Calling ControllerAttachVolume with a request missing VolumeID, ControllerName/PluginID, or ClientCSINodeID (the ClientCSINodeID==\"\" check returns the plain errors.New variant), or ToCSIRequest failing on malformed fields.","commonSituations":"A Nomad server bug or version skew emitting an under-populated controller attach request; custom automation invoking the client RPC directly with partial data; volume registration missing fields normally filled by the server.","solutions":["Ensure ClientCSINodeID is set — it comes from the node's CSI node registration; re-run node fingerprint/CSI node registration","Verify the volume registration has complete VolumeContext and volume ID","Upgrade/align server and client Nomad versions if the server is sending incomplete requests","Re-issue the volume publish workflow after correcting the request"],"exampleFix":"// before\nreq := &structs.ClientCSIControllerAttachVolumeRequest{PluginID: p, VolumeID: v} // ClientCSINodeID missing\n// after\nreq := &structs.ClientCSIControllerAttachVolumeRequest{PluginID: p, VolumeID: v, ClientCSINodeID: nodeID}","handlingStrategy":"validation","validationCode":"func validateAttachReq(req *structs.ClientCSIControllerAttachVolumeRequest) error {\n    if req.VolumeID == \"\" { return errors.New(\"VolumeID is required\") }\n    if req.ClientCSINodeID == \"\" { return errors.New(\"ClientCSINodeID is required\") }\n    if req.PluginID == \"\" { return errors.New(\"PluginID is required\") }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := validateAttachReq(req); err != nil {\n    // correct node CSI registration / volume registration before retrying\n    return fmt.Errorf(\"skip attach, invalid request: %w\", err)\n}","preventionTips":["Ensure `csi_node` fingerprint ran on the node so ClientCSINodeID exists","Re-run node registration if the node was re-fingerprinted","Keep server/client Nomad versions aligned","Validate volume registration fields with `nomad volume inspect` before publish"],"tags":["csi","validation","attach","request-conversion"],"backgroundTag":"csi-request-validation-failed","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"}