From d1381f2ac82c8622cc4eba929bb60a67d3273aa4 Mon Sep 17 00:00:00 2001 From: wanggangqiang Date: Tue, 10 Jan 2023 15:10:11 +0800 Subject: [PATCH 1/2] support replica count 3 for vos disk; --- Makefile | 2 +- pkg/disk/driver/types.go | 1 + pkg/disk/driver/utils.go | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0d0add3c..39397f1a 100644 --- a/Makefile +++ b/Makefile @@ -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/... diff --git a/pkg/disk/driver/types.go b/pkg/disk/driver/types.go index 01959268..14d5ce75 100644 --- a/pkg/disk/driver/types.go +++ b/pkg/disk/driver/types.go @@ -304,5 +304,6 @@ var VolumeTypeAttachConstraint = map[VolumeType][]InstanceType{ const ( DiskSingleReplicaType int = 1 DiskMultiReplicaType int = 2 + DiskThreeReplicaType int = 3 DefaultDiskReplicaType int = DiskMultiReplicaType ) diff --git a/pkg/disk/driver/utils.go b/pkg/disk/driver/utils.go index 59c2b08d..2d378f79 100644 --- a/pkg/disk/driver/utils.go +++ b/pkg/disk/driver/utils.go @@ -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: From 9d116138e6e1a76700031fb1e6d173bd68b47c56 Mon Sep 17 00:00:00 2001 From: wanggangqiang Date: Wed, 8 Feb 2023 16:40:15 +0800 Subject: [PATCH 2/2] get device path from volume id ranther than instance device path --- pkg/disk/rpcserver/nodeserver.go | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/pkg/disk/rpcserver/nodeserver.go b/pkg/disk/rpcserver/nodeserver.go index 7acd6398..dec1b4e5 100644 --- a/pkg/disk/rpcserver/nodeserver.go +++ b/pkg/disk/rpcserver/nodeserver.go @@ -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" @@ -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" @@ -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" @@ -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 { @@ -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. @@ -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" @@ -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"