From 43d036abfb520b31ff6a6fb9e39272a82fba13f1 Mon Sep 17 00:00:00 2001 From: ioito Date: Mon, 21 Oct 2019 11:25:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8D=8E=E4=B8=BA?= =?UTF-8?q?=E4=BA=91ucloud=E5=AE=89=E5=85=A8=E7=BB=84=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/multicloud/huawei/region.go | 10 +++++----- pkg/multicloud/ucloud/securitygroup.go | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/multicloud/huawei/region.go b/pkg/multicloud/huawei/region.go index e69a53365b..42e13a2cc9 100644 --- a/pkg/multicloud/huawei/region.go +++ b/pkg/multicloud/huawei/region.go @@ -512,17 +512,17 @@ func (self *SRegion) DeleteSecurityGroup(vpcId, secgroupId string) error { func (self *SRegion) SyncSecurityGroup(secgroupId string, vpcId string, name string, desc string, rules []secrules.SecurityRule) (string, error) { if len(secgroupId) > 0 { _, err := self.GetSecurityGroupDetails(secgroupId) - if err == cloudprovider.ErrNotSupported { + if err == cloudprovider.ErrNotFound { secgroupId = "" } else if err != nil { - return "", err + return "", errors.Wrapf(err, "self.GetSecurityGroupDetails(%s)", secgroupId) } } if len(secgroupId) == 0 { extID, err := self.CreateSecurityGroup(vpcId, name, desc) if err != nil { - return "", err + return "", errors.Wrap(err, "self.CreateSecurityGroup") } secgroupId = extID } @@ -708,11 +708,11 @@ func (self *SRegion) syncSecgroupRules(secgroupId string, rules []secrules.Secur var AddRules []secrules.SecurityRule if secgroup, err := self.GetSecurityGroupDetails(secgroupId); err != nil { - return err + return errors.Wrapf(err, "syncSecgroupRules.GetSecurityGroupDetails(%s)", secgroupId) } else { remoteRules, err := secgroup.GetRulesWithExtId() if err != nil { - return err + return errors.Wrap(err, "secgroup.GetRulesWithExtId") } sort.Sort(secrules.SecurityRuleSet(rules)) diff --git a/pkg/multicloud/ucloud/securitygroup.go b/pkg/multicloud/ucloud/securitygroup.go index 902adae389..d413de47d7 100644 --- a/pkg/multicloud/ucloud/securitygroup.go +++ b/pkg/multicloud/ucloud/securitygroup.go @@ -246,6 +246,9 @@ func (self *SRegion) GetSecurityGroups(secGroupId string, resourceId string) ([] } err := self.DoListAll("DescribeFirewall", params, &secgroups) if err != nil { + if strings.Contains(err.Error(), "not exist") { + return nil, cloudprovider.ErrNotFound + } return nil, err }