From e6be700ac246bba81b8f922cc829eaf8974ac244 Mon Sep 17 00:00:00 2001 From: "cheolho.kang" Date: Thu, 20 Mar 2025 09:20:56 +0900 Subject: [PATCH] feat: add `NodeStageVolume()` and `NodeUnstageVolume()` skeletons with validation for request arguments Signed-off-by: cheolho.kang --- pkg/nvmf/nodeserver.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/pkg/nvmf/nodeserver.go b/pkg/nvmf/nodeserver.go index 8329215..acb34ef 100644 --- a/pkg/nvmf/nodeserver.go +++ b/pkg/nvmf/nodeserver.go @@ -48,6 +48,13 @@ func (n *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCa }, }, }, + { + Type: &csi.NodeServiceCapability_Rpc{ + Rpc: &csi.NodeServiceCapability_RPC{ + Type: csi.NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME, + }, + }, + }, }, }, nil } @@ -102,11 +109,40 @@ func (n *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpub return &csi.NodeUnpublishVolumeResponse{}, nil } +// NodeStageVolume attaches the NVMe device to the node func (n *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) { + volumeID := req.GetVolumeId() + if volumeID == "" { + return nil, status.Error(codes.InvalidArgument, "NodeStageVolume Volume ID must be required") + } + + // Check for supported volume capabilities + if req.GetVolumeCapability() == nil { + return nil, status.Error(codes.InvalidArgument, "NodeStageVolume Volume capability is required") + } + + // Check for staging target path + if req.GetStagingTargetPath() == "" { + return nil, status.Error(codes.InvalidArgument, "NodeStageVolume Staging target path is required") + } + + klog.V(4).Infof("NodeStageVolume called for volume %s", volumeID) + return &csi.NodeStageVolumeResponse{}, nil } +// NodeUnstageVolume detaches the NVMe device from the node func (n *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) { + // Validate parameters + if req.VolumeId == "" { + return nil, status.Error(codes.InvalidArgument, "NodeUnstageVolume Volume ID must be provided") + } + if req.StagingTargetPath == "" { + return nil, status.Error(codes.InvalidArgument, "NodeUnstageVolume Staging target path must be provided") + } + + klog.V(4).Infof("NodeUnstageVolume called for volume %s", req.VolumeId) + return &csi.NodeUnstageVolumeResponse{}, nil }