From c83be637a349a775646e1f81bdb172be3d2c39c2 Mon Sep 17 00:00:00 2001 From: powerkimhub Date: Tue, 29 Nov 2022 07:01:35 +0000 Subject: [PATCH] Add NHNCloud exception codes --- api-runtime/common-runtime/ClusterManager.go | 14 +++++++++++-- .../iid-manager/IIDManager.go | 20 ++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/api-runtime/common-runtime/ClusterManager.go b/api-runtime/common-runtime/ClusterManager.go index 26ea4812e..da6cf8014 100644 --- a/api-runtime/common-runtime/ClusterManager.go +++ b/api-runtime/common-runtime/ClusterManager.go @@ -410,11 +410,21 @@ defer clusterSPLock.Unlock(connectionName, reqInfo.IId.NameId) driverIId := cres.IID{spUUID, ""} reqInfo.IId = driverIId + providerName, err := ccm.GetProviderNameByConnectionName(connectionName) + if err != nil { + cblog.Error(err) + return nil, err + } + // Create SP-UUID for NodeGroup list ngReqIIdList := []cres.IID{} ngInfoList := []cres.NodeGroupInfo{} - for _, info := range reqInfo.NodeGroupList { - nodeGroupUUID, err := iidm.New(connectionName, rsNodeGroup, info.IId.NameId) + for idx, info := range reqInfo.NodeGroupList { + nodeGroupUUID := "" + if providerName == "NHNCLOUD" && idx == 0 { + nodeGroupUUID = "default-worker" // fixed name in NHN + } + nodeGroupUUID, err = iidm.New(connectionName, rsNodeGroup, info.IId.NameId) if err != nil { cblog.Error(err) return nil, err diff --git a/cloud-control-manager/iid-manager/IIDManager.go b/cloud-control-manager/iid-manager/IIDManager.go index 6fbd6fffe..84b8b1ddf 100644 --- a/cloud-control-manager/iid-manager/IIDManager.go +++ b/cloud-control-manager/iid-manager/IIDManager.go @@ -357,8 +357,26 @@ func New(cloudConnectName string, rsType string, uid string) (string, error) { return uid, nil } + // MaxLength = 12, lower, number, Cannot use '-' if cccInfo.ProviderName == "AZURE" && rsType == "nodegroup" { - return uid, nil + retUID := strings.ToLower(strings.ReplaceAll(uid, "-", "")) + + if len(retUID) > 12 { + // #6 + #6 => #12 + retUID = uid[:6] + xid.New().String()[0:6] + } + return retUID, nil + } + + // MaxLenth = 20, lower, number, '-' + if cccInfo.ProviderName == "NHNCLOUD" && (rsType == "cluster" || rsType == "nodegroup") { + retUID := strings.ToLower(uid) + + if len(retUID) > 20 { + // #10 + #10 => #20 + retUID = uid[:10] + xid.New().String()[0:10] + } + return retUID, nil } // default length: 9 + 21 => 30 (NCP's ID Length, the shortest)