mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-19 11:30:24 +00:00
f4c80dec9a
in NodeStage RPC call we have to map the device to the node plugin and make sure the the device will be mounted to the global path in nodeUnstage request unmount the device from global path and unmap the device if the volume mode is block we will be creating a file inside a stageTargetPath and it will be considered as the global path Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
76 lines
2.2 KiB
Go
76 lines
2.2 KiB
Go
package util
|
|
|
|
import (
|
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
// ValidateNodeStageVolumeRequest validates the node stage request
|
|
func ValidateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) error {
|
|
if req.GetVolumeCapability() == nil {
|
|
return status.Error(codes.InvalidArgument, "volume capability missing in request")
|
|
}
|
|
|
|
if req.GetVolumeId() == "" {
|
|
return status.Error(codes.InvalidArgument, "volume ID missing in request")
|
|
}
|
|
|
|
if req.GetStagingTargetPath() == "" {
|
|
return status.Error(codes.InvalidArgument, "staging target path missing in request")
|
|
}
|
|
|
|
if req.GetSecrets() == nil || len(req.GetSecrets()) == 0 {
|
|
return status.Error(codes.InvalidArgument, "stage secrets cannot be nil or empty")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ValidateNodeUnstageVolumeRequest validates the node unstage request
|
|
func ValidateNodeUnstageVolumeRequest(req *csi.NodeUnstageVolumeRequest) error {
|
|
if req.GetVolumeId() == "" {
|
|
return status.Error(codes.InvalidArgument, "volume ID missing in request")
|
|
}
|
|
|
|
if req.GetStagingTargetPath() == "" {
|
|
return status.Error(codes.InvalidArgument, "staging target path missing in request")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ValidateNodePublishVolumeRequest validates the node publish request
|
|
func ValidateNodePublishVolumeRequest(req *csi.NodePublishVolumeRequest) error {
|
|
if req.GetVolumeCapability() == nil {
|
|
return status.Error(codes.InvalidArgument, "volume capability missing in request")
|
|
}
|
|
|
|
if req.GetVolumeId() == "" {
|
|
return status.Error(codes.InvalidArgument, "volume ID missing in request")
|
|
}
|
|
|
|
if req.GetTargetPath() == "" {
|
|
return status.Error(codes.InvalidArgument, "target path missing in request")
|
|
}
|
|
|
|
if req.GetStagingTargetPath() == "" {
|
|
return status.Error(codes.InvalidArgument, "staging target path missing in request")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// ValidateNodeUnpublishVolumeRequest validates the node unpublish request
|
|
func ValidateNodeUnpublishVolumeRequest(req *csi.NodeUnpublishVolumeRequest) error {
|
|
if req.GetVolumeId() == "" {
|
|
return status.Error(codes.InvalidArgument, "volume ID missing in request")
|
|
}
|
|
|
|
if req.GetTargetPath() == "" {
|
|
return status.Error(codes.InvalidArgument, "target path missing in request")
|
|
}
|
|
|
|
return nil
|
|
}
|