From 3a3f1fde7b639fc2f7d113b69bfb1c78829fb89b Mon Sep 17 00:00:00 2001 From: jichenjc Date: Sat, 11 Jul 2020 10:25:04 +0000 Subject: [PATCH] report error if security group not exist --- pkg/cloud/services/compute/instance.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/cloud/services/compute/instance.go b/pkg/cloud/services/compute/instance.go index 46bb3180d3..a88e3be696 100644 --- a/pkg/cloud/services/compute/instance.go +++ b/pkg/cloud/services/compute/instance.go @@ -326,6 +326,10 @@ func getSecurityGroups(is *Service, securityGroupParams []infrav1.SecurityGroupP return nil, err } + if len(SGList) == 0 { + return nil, fmt.Errorf("security group %s not found", sg.Name) + } + for _, group := range SGList { if isDuplicate(sgIDs, group.ID) { continue