Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for runtime err in RegisterCspNativeRes #1101

Merged
merged 1 commit into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/common/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func GetConnConfigList() (ConnConfigList, error) {
if err != nil {
CBLog.Error(err)
content := ConnConfigList{}
err := fmt.Errorf("an error occurred while requesting to CB-Spider")
err := fmt.Errorf("Error from CB-Spider: " + err.Error())
return content, err
}

Expand Down
34 changes: 21 additions & 13 deletions src/core/mcir/securitygroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,35 @@ func CreateSecurityGroup(nsId string, u *TbSecurityGroupReq, option string) (TbS

if err != nil {
common.CBLog.Error(err)
err := fmt.Errorf("Cannot ListResourceId securityGroup")
err := fmt.Errorf("Cannot list vNet Ids for securityGroup")
return TbSecurityGroupInfo{}, err
}

var content struct {
VNet []TbVNetInfo `json:"vNet"`
}
content.VNet = resourceList.([]TbVNetInfo) // type assertion (interface{} -> array)
if resourceList != nil {
var content struct {
VNet []TbVNetInfo `json:"vNet"`
}
content.VNet = resourceList.([]TbVNetInfo) // type assertion (interface{} -> array)

if len(resourceList.([]TbVNetInfo)) == 0 {
errString := "There is no " + common.StrVNet + " resource in " + nsId
err := fmt.Errorf(errString)
common.CBLog.Error(err)
return TbSecurityGroupInfo{}, err
}

if len(content.VNet) == 0 {
errString := "There is no " + common.StrVNet + " resource in " + nsId
// Assign random temporal ID to u.VNetId (should be in the same Connection with SG)
for _, r := range content.VNet {
if r.ConnectionName == u.ConnectionName {
u.VNetId = r.Id
}
}
} else {
errString := "nil was returned for vNet list in " + nsId
err := fmt.Errorf(errString)
common.CBLog.Error(err)
return TbSecurityGroupInfo{}, err
}

for _, r := range content.VNet {
if r.ConnectionName == u.ConnectionName {
u.VNetId = r.Id
}
}
}

vNetInfo := TbVNetInfo{}
Expand Down