mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-26 23:10:22 +00:00
Merge pull request #372 from Madhu-1/fix-err
Fix error string as per golang standard
This commit is contained in:
commit
4df939793b
@ -106,12 +106,12 @@ func (cs *ControllerServer) validateCreateVolumeRequest(req *csi.CreateVolumeReq
|
||||
}
|
||||
|
||||
if req.GetName() == "" {
|
||||
return status.Error(codes.InvalidArgument, "Volume Name cannot be empty")
|
||||
return status.Error(codes.InvalidArgument, "volume Name cannot be empty")
|
||||
}
|
||||
|
||||
reqCaps := req.GetVolumeCapabilities()
|
||||
if reqCaps == nil {
|
||||
return status.Error(codes.InvalidArgument, "Volume Capabilities cannot be empty")
|
||||
return status.Error(codes.InvalidArgument, "volume Capabilities cannot be empty")
|
||||
}
|
||||
|
||||
for _, cap := range reqCaps {
|
||||
|
@ -47,17 +47,17 @@ func (cs *ControllerServer) validateVolumeReq(req *csi.CreateVolumeRequest) erro
|
||||
}
|
||||
// Check sanity of request Name, Volume Capabilities
|
||||
if len(req.Name) == 0 {
|
||||
return status.Error(codes.InvalidArgument, "Volume Name cannot be empty")
|
||||
return status.Error(codes.InvalidArgument, "volume Name cannot be empty")
|
||||
}
|
||||
if req.VolumeCapabilities == nil {
|
||||
return status.Error(codes.InvalidArgument, "Volume Capabilities cannot be empty")
|
||||
return status.Error(codes.InvalidArgument, "volume Capabilities cannot be empty")
|
||||
}
|
||||
options := req.GetParameters()
|
||||
if value, ok := options["clusterID"]; !ok || len(value) == 0 {
|
||||
return status.Error(codes.InvalidArgument, "Missing or empty cluster ID to provision volume from")
|
||||
return status.Error(codes.InvalidArgument, "missing or empty cluster ID to provision volume from")
|
||||
}
|
||||
if value, ok := options["pool"]; !ok || len(value) == 0 {
|
||||
return status.Error(codes.InvalidArgument, "Missing or empty pool name to provision volume from")
|
||||
return status.Error(codes.InvalidArgument, "missing or empty pool name to provision volume from")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -190,12 +190,12 @@ func (cs *ControllerServer) createBackingImage(rbdVol *rbdVolume, req *csi.Creat
|
||||
func (cs *ControllerServer) checkSnapshot(req *csi.CreateVolumeRequest, rbdVol *rbdVolume) error {
|
||||
snapshot := req.VolumeContentSource.GetSnapshot()
|
||||
if snapshot == nil {
|
||||
return status.Error(codes.InvalidArgument, "Volume Snapshot cannot be empty")
|
||||
return status.Error(codes.InvalidArgument, "volume Snapshot cannot be empty")
|
||||
}
|
||||
|
||||
snapshotID := snapshot.GetSnapshotId()
|
||||
if len(snapshotID) == 0 {
|
||||
return status.Error(codes.InvalidArgument, "Volume Snapshot ID cannot be empty")
|
||||
return status.Error(codes.InvalidArgument, "volume Snapshot ID cannot be empty")
|
||||
}
|
||||
|
||||
rbdSnap := &rbdSnapshot{}
|
||||
@ -203,7 +203,7 @@ func (cs *ControllerServer) checkSnapshot(req *csi.CreateVolumeRequest, rbdVol *
|
||||
if _, ok := err.(ErrSnapNotFound); !ok {
|
||||
return status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
return status.Error(codes.InvalidArgument, "Missing requested Snapshot ID")
|
||||
return status.Error(codes.InvalidArgument, "missing requested Snapshot ID")
|
||||
}
|
||||
|
||||
err := restoreSnapshot(rbdVol, rbdSnap, rbdVol.AdminID, req.GetSecrets())
|
||||
@ -224,7 +224,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
// For now the image get unconditionally deleted, but here retention policy can be checked
|
||||
volumeID := req.GetVolumeId()
|
||||
if volumeID == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "Empty volume ID in request")
|
||||
return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
|
||||
}
|
||||
volumeIDMutex.LockKey(volumeID)
|
||||
defer func() {
|
||||
@ -287,11 +287,11 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
// are supported.
|
||||
func (cs *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) {
|
||||
if req.GetVolumeId() == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "Empty volume ID in request")
|
||||
return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
|
||||
}
|
||||
|
||||
if len(req.VolumeCapabilities) == 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "Empty volume capabilities in request")
|
||||
return nil, status.Error(codes.InvalidArgument, "empty volume capabilities in request")
|
||||
}
|
||||
|
||||
for _, cap := range req.VolumeCapabilities {
|
||||
@ -326,7 +326,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
|
||||
err := genVolFromVolID(rbdVol, req.GetSourceVolumeId(), req.GetSecrets())
|
||||
if err != nil {
|
||||
if _, ok := err.(ErrImageNotFound); ok {
|
||||
return nil, status.Errorf(codes.NotFound, "Source Volume ID %s not found", req.GetSourceVolumeId())
|
||||
return nil, status.Errorf(codes.NotFound, "source Volume ID %s not found", req.GetSourceVolumeId())
|
||||
}
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
@ -402,10 +402,10 @@ func (cs *ControllerServer) validateSnapshotReq(req *csi.CreateSnapshotRequest)
|
||||
|
||||
// Check sanity of request Snapshot Name, Source Volume Id
|
||||
if len(req.Name) == 0 {
|
||||
return status.Error(codes.InvalidArgument, "Snapshot Name cannot be empty")
|
||||
return status.Error(codes.InvalidArgument, "snapshot Name cannot be empty")
|
||||
}
|
||||
if len(req.SourceVolumeId) == 0 {
|
||||
return status.Error(codes.InvalidArgument, "Source Volume ID cannot be empty")
|
||||
return status.Error(codes.InvalidArgument, "source Volume ID cannot be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -467,7 +467,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
|
||||
|
||||
snapshotID := req.GetSnapshotId()
|
||||
if len(snapshotID) == 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "Snapshot ID cannot be empty")
|
||||
return nil, status.Error(codes.InvalidArgument, "snapshot ID cannot be empty")
|
||||
}
|
||||
|
||||
snapshotIDMutex.LockKey(snapshotID)
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/ceph/ceph-csi/pkg/csi-common"
|
||||
csicommon "github.com/ceph/ceph-csi/pkg/csi-common"
|
||||
"github.com/ceph/ceph-csi/pkg/util"
|
||||
|
||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
@ -46,15 +46,15 @@ type NodeServer struct {
|
||||
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
|
||||
targetPath := req.GetTargetPath()
|
||||
if targetPath == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "Empty target path in request")
|
||||
return nil, status.Error(codes.InvalidArgument, "empty target path in request")
|
||||
}
|
||||
|
||||
if req.GetVolumeCapability() == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "Empty volume capability in request")
|
||||
return nil, status.Error(codes.InvalidArgument, "empty volume capability in request")
|
||||
}
|
||||
|
||||
if req.GetVolumeId() == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "Empty volume ID in request")
|
||||
return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
|
||||
}
|
||||
|
||||
targetPathMutex.LockKey(targetPath)
|
||||
@ -190,11 +190,11 @@ func (ns *NodeServer) createTargetPath(targetPath string, isBlock bool) (bool, e
|
||||
func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
|
||||
targetPath := req.GetTargetPath()
|
||||
if targetPath == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "Empty target path in request")
|
||||
return nil, status.Error(codes.InvalidArgument, "empty target path in request")
|
||||
}
|
||||
|
||||
if req.GetVolumeId() == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "Empty volume ID in request")
|
||||
return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
|
||||
}
|
||||
|
||||
targetPathMutex.LockKey(targetPath)
|
||||
@ -217,7 +217,7 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
|
||||
if notMnt {
|
||||
// TODO should consider deleting path instead of returning error,
|
||||
// once all codes become ready for csi 1.0.
|
||||
return nil, status.Error(codes.NotFound, "Volume not mounted")
|
||||
return nil, status.Error(codes.NotFound, "volume not mounted")
|
||||
}
|
||||
|
||||
devicePath, cnt, err := mount.GetDeviceNameFromMount(ns.mounter, targetPath)
|
||||
|
@ -21,13 +21,14 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"k8s.io/klog"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// ExecCommand executes passed in program with args and returns seperate stdout and stderr streams
|
||||
// ExecCommand executes passed in program with args and returns separate stdout and stderr streams
|
||||
func ExecCommand(program string, args ...string) (stdout, stderr []byte, err error) {
|
||||
var (
|
||||
cmd = exec.Command(program, args...) // nolint: gosec
|
||||
@ -191,7 +192,7 @@ func GetOMapValue(monitors, adminID, key, poolName, namespace, oMapName, oMapKey
|
||||
klog.Errorf("failed getting omap value for key (%s) from omap (%s) in pool (%s): (%v)",
|
||||
oMapKey, oMapName, poolName, err)
|
||||
|
||||
return "", fmt.Errorf("error (%v) occured, command output streams is (%s)",
|
||||
return "", fmt.Errorf("error (%v) occurred, command output streams is (%s)",
|
||||
err.Error(), stdoutanderr)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user