Skip to content

Commit

Permalink
Merge pull request #210 from qiangzii/master
Browse files Browse the repository at this point in the history
update device path;
  • Loading branch information
liangcd authored Feb 21, 2023
2 parents 6d4d8ce + 9d11613 commit b292a83
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
.PHONY: all disk

DISK_IMAGE_NAME=csiplugin/csi-qingcloud
DISK_VERSION=v1.3.6
DISK_VERSION=v1.3.7
ROOT_PATH=$(pwd)
PACKAGE_LIST=./cmd/... ./pkg/...

Expand Down
1 change: 1 addition & 0 deletions pkg/disk/driver/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,5 +304,6 @@ var VolumeTypeAttachConstraint = map[VolumeType][]InstanceType{
const (
DiskSingleReplicaType int = 1
DiskMultiReplicaType int = 2
DiskThreeReplicaType int = 3
DefaultDiskReplicaType int = DiskMultiReplicaType
)
7 changes: 5 additions & 2 deletions pkg/disk/driver/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ limitations under the License.
package driver

import (
"io/ioutil"
"strings"

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/yunify/qingcloud-csi/pkg/common"
"io/ioutil"
"k8s.io/klog"
"strings"
)

// Check replica
// Support: 2 MultiReplicas, 1 SingleReplica
func IsValidReplica(replica int) bool {
switch replica {
case DiskThreeReplicaType:
return true
case DiskMultiReplicaType:
return true
case DiskSingleReplicaType:
Expand Down
34 changes: 22 additions & 12 deletions pkg/disk/rpcserver/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ func NewNodeServer(d *driver.DiskDriver, c cloud.CloudManager, mnt *mount.SafeFo
// If the volume corresponding to the volume id has already been published at the specified target path,
// and is compatible with the specified volume capability and readonly flag, the plugin MUST reply 0 OK.
// csi.NodePublishVolumeRequest: volume id + Required
// target path + Required
// volume capability + Required
// read only + Required (This field is NOT provided when requesting in Kubernetes)
//
// target path + Required
// volume capability + Required
// read only + Required (This field is NOT provided when requesting in Kubernetes)
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.
NodePublishVolumeResponse, error) {
funcName := "NodePublishVolume"
Expand Down Expand Up @@ -152,7 +153,8 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
}

// csi.NodeUnpublishVolumeRequest: volume id + Required
// target path + Required
//
// target path + Required
func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.
NodeUnpublishVolumeResponse, error) {
funcName := "NodeUnpublishVolume"
Expand Down Expand Up @@ -197,8 +199,9 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu

// This operation MUST be idempotent
// csi.NodeStageVolumeRequest: volume id + Required
// stage target path + Required
// volume capability + Required
//
// stage target path + Required
// volume capability + Required
func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse,
error) {
funcName := "NodeStageVolume"
Expand Down Expand Up @@ -266,12 +269,15 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol

// get device path
devicePath := ""
devicePrefix := "/dev/disk/by-id/virtio-"
if volInfo.Instance != nil && volInfo.Instance.Device != nil && *volInfo.Instance.Device != "" {
devicePath = *volInfo.Instance.Device
// devicePath = *volInfo.Instance.Device
devicePath = devicePrefix + volumeId
klog.Infof("Find volume %s's device path is %s", volumeId, devicePath)
} else {
return nil, status.Errorf(codes.Internal, "Cannot find device path of volume %s", volumeId)
}

// do mount
klog.Infof("Mounting %s to %s format %s...", volumeId, targetPath, fsType)
if err := ns.mounter.FormatAndMount(devicePath, targetPath, fsType, []string{}); err != nil {
Expand All @@ -283,7 +289,9 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol

// This operation MUST be idempotent
// csi.NodeUnstageVolumeRequest: volume id + Required
// target path + Required
//
// target path + Required
//
// In block volume mode, the target path is never mounted to
// so this call will be a no-op
func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.
Expand Down Expand Up @@ -397,8 +405,9 @@ func (ns *NodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoReque

// NodeExpandVolume will expand filesystem of volume.
// Input Parameters:
// volume id: REQUIRED
// volume path: REQUIRED
//
// volume id: REQUIRED
// volume path: REQUIRED
func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (
*csi.NodeExpandVolumeResponse, error) {
funcName := "NodeExpandVolume"
Expand Down Expand Up @@ -476,8 +485,9 @@ func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV

// NodeGetVolumeStats
// Input Arguments:
// volume id: REQUIRED
// volume path: REQUIRED
//
// volume id: REQUIRED
// volume path: REQUIRED
func (ns *NodeServer) NodeGetVolumeStats(ctx context.Context,
req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
funcName := "NodeGetVolumeStats"
Expand Down

0 comments on commit b292a83

Please sign in to comment.