From ed830ac1537c0d5e4aafee3628ab8981744a5f1f Mon Sep 17 00:00:00 2001 From: wanggangqiang Date: Tue, 19 Mar 2024 14:31:07 +0800 Subject: [PATCH 1/2] add instance type 1002 support --- Makefile | 2 +- pkg/disk/driver/types.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index da05308..b940095 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ .PHONY: all disk DISK_IMAGE_NAME=csiplugin/csi-qingcloud -DISK_VERSION=v1.4.0 +DISK_VERSION=v1.4.1-alpha ROOT_PATH=$(pwd) PACKAGE_LIST=./cmd/... ./pkg/... diff --git a/pkg/disk/driver/types.go b/pkg/disk/driver/types.go index 450101c..396708e 100644 --- a/pkg/disk/driver/types.go +++ b/pkg/disk/driver/types.go @@ -188,6 +188,7 @@ const ( TPSC3InstanceType InstanceType = 403 TPSC4InstanceType InstanceType = 404 TPSC5InstanceType InstanceType = 405 + AMDFireProS7150InstanceType InstanceType = 1002 ) var InstanceTypeName = map[InstanceType]string{ @@ -208,6 +209,7 @@ var InstanceTypeName = map[InstanceType]string{ 403: "TPSC3", 404: "TPSC4", 405: "TPSC5", + 1002: "AMDFireProS7150", } var InstanceTypeValue = map[string]InstanceType{ @@ -228,6 +230,7 @@ var InstanceTypeValue = map[string]InstanceType{ "TPSC3": 403, "TPSC4": 404, "TPSC5": 405, + "AMDFireProS7150": 1002, } var InstanceTypeAttachPreferred = map[InstanceType]VolumeType{ @@ -248,6 +251,7 @@ var InstanceTypeAttachPreferred = map[InstanceType]VolumeType{ TPSC3InstanceType: ThirdPartyStorageType, TPSC4InstanceType: ThirdPartyStorageType, TPSC5InstanceType: ThirdPartyStorageType, + AMDFireProS7150InstanceType: NeonSANHDDVolumeType, } var VolumeTypeAttachConstraint = map[VolumeType][]InstanceType{ @@ -263,6 +267,7 @@ var VolumeTypeAttachConstraint = map[VolumeType][]InstanceType{ Enterprise2InstanceType, PremiumInstanceType, NvidiaAmpereG3InstanceType, + AMDFireProS7150InstanceType, }, SuperHighPerformanceVolumeType: { SuperHighPerformanceInstanceType, @@ -282,6 +287,7 @@ var VolumeTypeAttachConstraint = map[VolumeType][]InstanceType{ EnterpriseCompute3InstanceType, PremiumInstanceType, NvidiaAmpereG3InstanceType, + AMDFireProS7150InstanceType, }, NeonSANHDDVolumeType: { HighPerformanceInstanceType, @@ -295,6 +301,7 @@ var VolumeTypeAttachConstraint = map[VolumeType][]InstanceType{ EnterpriseCompute3InstanceType, PremiumInstanceType, NvidiaAmpereG3InstanceType, + AMDFireProS7150InstanceType, }, NeonSANRDMAVolumeType: { HighPerformanceInstanceType, @@ -308,6 +315,7 @@ var VolumeTypeAttachConstraint = map[VolumeType][]InstanceType{ EnterpriseCompute3InstanceType, PremiumInstanceType, NvidiaAmpereG3InstanceType, + AMDFireProS7150InstanceType, }, ThirdPartyStorageType: { StandardInstanceType, From ef44f895dd47a7ffc3845160d70d21b1f15783cf Mon Sep 17 00:00:00 2001 From: wanggangqiang Date: Wed, 11 Sep 2024 10:06:35 +0800 Subject: [PATCH 2/2] add placeGroupID support for storageclass --- Makefile | 2 +- pkg/cloud/cloud_manager.go | 2 +- pkg/cloud/mock/mock_cloud_manager.go | 2 +- pkg/cloud/qingcloud_manager.go | 9 ++++++--- pkg/cloud/qingcloud_manager_test.go | 2 +- pkg/disk/driver/storageclass.go | 14 ++++++++++++++ pkg/disk/rpcserver/controllerserver.go | 2 +- .../yunify/qingcloud-sdk-go/service/volume.go | 1 + 8 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index b940095..a715eab 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ .PHONY: all disk DISK_IMAGE_NAME=csiplugin/csi-qingcloud -DISK_VERSION=v1.4.1-alpha +DISK_VERSION=v1.4.1 ROOT_PATH=$(pwd) PACKAGE_LIST=./cmd/... ./pkg/... diff --git a/pkg/cloud/cloud_manager.go b/pkg/cloud/cloud_manager.go index ebc175a..9bad339 100644 --- a/pkg/cloud/cloud_manager.go +++ b/pkg/cloud/cloud_manager.go @@ -39,7 +39,7 @@ type VolumeManager interface { // Return: // volume id, nil: succeed to create volume and return volume id // nil, error: failed to create volume - CreateVolume(volName string, requestSize int, replicas int, volType int, zone string, containerConfID string, rg string) (volId string, err error) + CreateVolume(volName string, requestSize int, replicas int, volType int, zone string, containerConfID string, rg string, placeGroupID string) (volId string, err error) // DeleteVolume deletes volume by id. // Return: // nil: succeed to delete volume diff --git a/pkg/cloud/mock/mock_cloud_manager.go b/pkg/cloud/mock/mock_cloud_manager.go index 101eba6..4f96867 100644 --- a/pkg/cloud/mock/mock_cloud_manager.go +++ b/pkg/cloud/mock/mock_cloud_manager.go @@ -160,7 +160,7 @@ func (m *MockCloudManager) FindVolumeByName(volName string) (volInfo *qcservice. return nil, nil } -func (m *MockCloudManager) CreateVolume(volName string, requestSize int, replicas int, volType int, zone string, containerConfID string, rg string) ( +func (m *MockCloudManager) CreateVolume(volName string, requestSize int, replicas int, volType int, zone string, containerConfID string, rg string, placeGroupPD string) ( volId string, err error) { exVol, err := m.FindVolumeByName(volName) if err != nil { diff --git a/pkg/cloud/qingcloud_manager.go b/pkg/cloud/qingcloud_manager.go index 5948fc9..07d89b1 100644 --- a/pkg/cloud/qingcloud_manager.go +++ b/pkg/cloud/qingcloud_manager.go @@ -302,7 +302,7 @@ func (cm *qingCloudManager) FindVolumeByName(name string) (volume *qcservice.Vol // 1. format volume size // 2. create volume // 3. wait job -func (qm *qingCloudManager) CreateVolume(volName string, requestSize int, replicas int, volType int, zone string, containerConfID string, rg string) ( +func (qm *qingCloudManager) CreateVolume(volName string, requestSize int, replicas int, volType int, zone string, containerConfID string, rg string, placeGroupID string) ( newVolId string, err error) { // 0. Set CreateVolume args // create volume count @@ -326,9 +326,12 @@ func (qm *qingCloudManager) CreateVolume(volName string, requestSize int, replic if (volType == driver.NeonSANVolumeType.Int() || volType == driver.NeonSANHDDVolumeType.Int() || volType == driver.NeonSANRDMAVolumeType.Int()) && rg != "" { input.RG = &rg } + if placeGroupID != "" { + input.PlaceGroupID = &placeGroupID + } - klog.Infof("Call IaaS CreateVolume request name: %s, size: %d GB, type: %d, zone: %s, count: %d, replica: %s, replica_count: %d, container_conf_id: %s, rg: %s", - *input.VolumeName, *input.Size, *input.VolumeType, *input.Zone, *input.Count, *input.Repl, *input.ReplicaCount, containerConfID, rg) + klog.Infof("Call IaaS CreateVolume request name: %s, size: %d GB, type: %d, zone: %s, count: %d, replica: %s, replica_count: %d, container_conf_id: %s, rg: %s, place_group_id: %s", + *input.VolumeName, *input.Size, *input.VolumeType, *input.Zone, *input.Count, *input.Repl, *input.ReplicaCount, containerConfID, rg, placeGroupID) // 1. Create volume output, err := qm.volumeService.CreateVolumes(input) diff --git a/pkg/cloud/qingcloud_manager_test.go b/pkg/cloud/qingcloud_manager_test.go index 746f2fd..180f6eb 100644 --- a/pkg/cloud/qingcloud_manager_test.go +++ b/pkg/cloud/qingcloud_manager_test.go @@ -67,7 +67,7 @@ func TestQingCloudManager_CreateVolume(t *testing.T) { } for _, test := range tests { - volId, err := cfg.CreateVolume(test.volName, test.volSize, test.volRepl, test.volType, test.volZone, "", "") + volId, err := cfg.CreateVolume(test.volName, test.volSize, test.volRepl, test.volType, test.volZone, "", "", "") if err != nil { if !test.isError { t.Errorf("testcase %s: expect error %t, but actually error: %s", test.name, test.isError, err) diff --git a/pkg/disk/driver/storageclass.go b/pkg/disk/driver/storageclass.go index 1fe13c6..ff6612d 100644 --- a/pkg/disk/driver/storageclass.go +++ b/pkg/disk/driver/storageclass.go @@ -36,6 +36,7 @@ const ( StorageClassTagsName = "tags" StorageClassContainerConfID = "containerConfID" StorageClassRG = "rg" + StorageClassPlaceGroupID = "placeGroupID" ) type QingStorageClass struct { @@ -48,6 +49,7 @@ type QingStorageClass struct { tags []string containerConfID string rg string + placeGroupID string } // NewDefaultQingStorageClassFromType create default qingStorageClass by specified volume type @@ -73,6 +75,7 @@ func NewQingStorageClassFromMap(opt map[string]string, topology *Topology) (*Qin replica := -1 containerConfID := "" rg := "" + placeGroupID := "" var tags []string for k, v := range opt { switch strings.ToLower(k) { @@ -123,6 +126,8 @@ func NewQingStorageClassFromMap(opt map[string]string, topology *Topology) (*Qin containerConfID = v case strings.ToLower(StorageClassRG): rg = v + case strings.ToLower(StorageClassPlaceGroupID): + placeGroupID = v } } @@ -155,6 +160,7 @@ func NewQingStorageClassFromMap(opt map[string]string, topology *Topology) (*Qin sc.setTags(tags) sc.setContainerConfID(containerConfID) sc.setRG(rg) + sc.setPlaceGroupID(placeGroupID) return sc, nil } @@ -193,6 +199,10 @@ func (sc QingStorageClass) GetRG() string { return sc.rg } +func (sc QingStorageClass) GetPlaceGroupID() string { + return sc.placeGroupID +} + func (sc *QingStorageClass) setFsType(fs string) error { if !IsValidFileSystemType(fs) { return fmt.Errorf("unsupported filesystem type %s", fs) @@ -233,6 +243,10 @@ func (sc *QingStorageClass) setRG(rg string) { sc.rg = rg } +func (sc *QingStorageClass) setPlaceGroupID(placeGroupID string) { + sc.placeGroupID = placeGroupID +} + // FormatVolumeSize transfer to proper volume size func (sc QingStorageClass) FormatVolumeSizeByte(sizeByte int64) int64 { if sizeByte <= sc.GetMinSizeByte() { diff --git a/pkg/disk/rpcserver/controllerserver.go b/pkg/disk/rpcserver/controllerserver.go index 30ea4d2..cd02749 100644 --- a/pkg/disk/rpcserver/controllerserver.go +++ b/pkg/disk/rpcserver/controllerserver.go @@ -162,7 +162,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol requiredSizeGib := common.ByteCeilToGib(requiredSizeByte) klog.Infof("%s: Creating empty volume %s with %d Gib in zone %s...", hash, volName, requiredSizeGib, top.GetZone()) - newVolId, err := cs.cloud.CreateVolume(volName, requiredSizeGib, sc.GetReplica(), sc.GetDiskType().Int(), top.GetZone(), sc.GetContainerConfID(), sc.GetRG()) + newVolId, err := cs.cloud.CreateVolume(volName, requiredSizeGib, sc.GetReplica(), sc.GetDiskType().Int(), top.GetZone(), sc.GetContainerConfID(), sc.GetRG(), sc.GetPlaceGroupID()) if err != nil { klog.Errorf("%s: Failed to create volume %s, error: %v", hash, volName, err) return nil, status.Error(codes.Internal, err.Error()) diff --git a/vendor/github.com/yunify/qingcloud-sdk-go/service/volume.go b/vendor/github.com/yunify/qingcloud-sdk-go/service/volume.go index a03f2b8..3b5de22 100644 --- a/vendor/github.com/yunify/qingcloud-sdk-go/service/volume.go +++ b/vendor/github.com/yunify/qingcloud-sdk-go/service/volume.go @@ -216,6 +216,7 @@ type CreateVolumesInput struct { ReplicaCount *int `json:"replica_count" name:"replica_count" location:"params"` ContainerConfID *string `json:"container_conf_id" name:"container_conf_id" location:"params"` RG *string `json:"rg" name:"rg" location:"params"` + PlaceGroupID *string `json:"place_group_id" name:"place_group_id" location:"params"` } func (v *CreateVolumesInput) Validate() error {