From a02a8def8cc5fadd5e3da208f985affbbed972d9 Mon Sep 17 00:00:00 2001 From: powerkimhub Date: Wed, 26 Oct 2022 00:46:51 +0900 Subject: [PATCH] PMKS Quick Release --- api-runtime/common-runtime/ClusterManager.go | 7 ++++--- api-runtime/common-runtime/CommonManager.go | 22 +++++++++++++++++++- api-runtime/rest-runtime/ClusterRest.go | 18 ++++++++-------- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/api-runtime/common-runtime/ClusterManager.go b/api-runtime/common-runtime/ClusterManager.go index 6a35f6349..f566ea705 100644 --- a/api-runtime/common-runtime/ClusterManager.go +++ b/api-runtime/common-runtime/ClusterManager.go @@ -513,7 +513,7 @@ defer clusterSPLock.Unlock(connectionName, reqInfo.IId.NameId) func setResourcesNameId(connectionName string, info *cres.ClusterInfo) error { //+++++++++++++++++++++ Set NetworkInfo's NameId - netInfo := info.Network + netInfo := &info.Network // (1) VpcIID // get spiderIID vpcIIDInfo, err := iidRWLock.GetIIDbySystemID(iidm.IIDSGROUP, connectionName, rsVPC, netInfo.VpcIID) @@ -857,6 +857,7 @@ defer clusterSPLock.Unlock(connectionName, clusterName) } // driverIID + nodeGroupNameId := reqInfo.IId.NameId driverIId := cres.IID{nodeGroupUUID, ""} reqInfo.IId = driverIId @@ -867,7 +868,7 @@ defer clusterSPLock.Unlock(connectionName, clusterName) return nil, err } - ngSpiderIId := cres.IID{reqInfo.IId.NameId, nodeGroupUUID + ":" + ngInfo.IId.SystemId} + ngSpiderIId := cres.IID{nodeGroupNameId, nodeGroupUUID + ":" + ngInfo.IId.SystemId} _, err2 := iidRWLock.CreateIID(iidm.NGGROUP, connectionName, clusterName, ngSpiderIId) // clusterName => rsType if err2 != nil { cblog.Error(err2) @@ -1013,7 +1014,7 @@ func getClusterDriverIIDNodeGroupDriverIID(connectionName string, clusterName st } // (2) Get NodeGroup's DriverIID - ngIIdInfoList, err := getAllClusterIIDInfoList(connectionName) + ngIIdInfoList, err := getAllNodeGroupIIDInfoList(connectionName) if err != nil { cblog.Error(err) return cres.IID{}, cres.IID{}, err diff --git a/api-runtime/common-runtime/CommonManager.go b/api-runtime/common-runtime/CommonManager.go index 270454bd4..68e1dbe1a 100644 --- a/api-runtime/common-runtime/CommonManager.go +++ b/api-runtime/common-runtime/CommonManager.go @@ -986,7 +986,7 @@ func DeleteResource(connectionName string, rsType string, nameID string, force s } } } - // @todo Should we also delete the SG list of this VPC ? + // @todo Should we also delete the SG list of this VPC ? NO, We Can't delete the VPC had SGs case rsSG: _, err = iidRWLock.DeleteIID(iidm.SGGROUP, connectionName, iidInfo.ResourceType/*vpcName*/, cres.IID{nameID, ""}) @@ -1022,6 +1022,26 @@ func DeleteResource(connectionName string, rsType string, nameID string, force s } } + // for NodeGroup list + // key-value structure: ~/{NODEGROUP}/{ConnectionName}/{Cluster-NameId}/{NodeGroup-reqNameId} [nodegroup-driverNameId:nodegroup-driverSystemId] # Cluster NameId => rsType + ngIIdInfoList, err2 := iidRWLock.ListIID(iidm.NGGROUP, connectionName, iidInfo.IId.NameId/*clusterName*/) + if err2 != nil { + cblog.Error(err) + if force != "true" { + return false, "", err + } + } + for _, ngIIdInfo := range ngIIdInfoList { + _, err := iidRWLock.DeleteIID(iidm.NGGROUP, connectionName, iidInfo.IId.NameId/*clusterName*/, ngIIdInfo.IId) + if err != nil { + cblog.Error(err) + if force != "true" { + return false, "", err + } + } + } + + default: // ex) KeyPair, Disk _, err = iidRWLock.DeleteIID(iidm.IIDSGROUP, connectionName, rsType, iidInfo.IId) if err != nil { diff --git a/api-runtime/rest-runtime/ClusterRest.go b/api-runtime/rest-runtime/ClusterRest.go index 46e97d05f..c48d72fe0 100644 --- a/api-runtime/rest-runtime/ClusterRest.go +++ b/api-runtime/rest-runtime/ClusterRest.go @@ -224,13 +224,13 @@ func attachNameSpaceToName(nameSpace string, clusterInfo *cres.ClusterInfo) { clusterInfo.Network.VpcIID.NameId = nameSpace + clusterInfo.Network.VpcIID.NameId // (2) Network's SubnetIIDs - for idx, _ := range clusterInfo.Network.SubnetIIDs { - clusterInfo.Network.SubnetIIDs[idx].NameId = nameSpace + clusterInfo.Network.SubnetIIDs[idx].NameId - } + //for idx, _ := range clusterInfo.Network.SubnetIIDs { + // clusterInfo.Network.SubnetIIDs[idx].NameId = nameSpace + clusterInfo.Network.SubnetIIDs[idx].NameId + //} // (3) Network's SecurityGroupsIIDs - for idx, _ := range clusterInfo.Network.SubnetIIDs { - clusterInfo.Network.SubnetIIDs[idx].NameId = nameSpace + clusterInfo.Network.SubnetIIDs[idx].NameId + for idx, _ := range clusterInfo.Network.SecurityGroupIIDs { + clusterInfo.Network.SecurityGroupIIDs[idx].NameId = nameSpace + clusterInfo.Network.SecurityGroupIIDs[idx].NameId } // (4) NodeGroup's KeyPairIID @@ -289,10 +289,10 @@ func detachNameSpaceFromName(nameSpace string, clusterInfo *cres.ClusterInfo) { clusterInfo.Network.VpcIID.NameId = strings.Replace(clusterInfo.Network.VpcIID.NameId, nameSpace, "", 1) // (2) Network's SubnetIIDs - for idx, _ := range clusterInfo.Network.SubnetIIDs { - clusterInfo.Network.SubnetIIDs[idx].NameId = - strings.Replace(clusterInfo.Network.SubnetIIDs[idx].NameId, nameSpace, "", 1) - } + //for idx, _ := range clusterInfo.Network.SubnetIIDs { + // clusterInfo.Network.SubnetIIDs[idx].NameId = + // strings.Replace(clusterInfo.Network.SubnetIIDs[idx].NameId, nameSpace, "", 1) + //} // (3) Network's SecurityGroupsIIDs for idx, _ := range clusterInfo.Network.SecurityGroupIIDs {