From 3d76a82d788a784ccd22d3ce072f91fd32bcaa1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Thu, 29 Nov 2018 11:38:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=99=9A=E6=8B=9F=E6=9C=BA?= =?UTF-8?q?=E6=97=B6=E9=81=BF=E5=85=8D=E6=97=A0=E9=99=90=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/util/qcloud/instance.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/pkg/util/qcloud/instance.go b/pkg/util/qcloud/instance.go index 294ad1fef1..062060f480 100644 --- a/pkg/util/qcloud/instance.go +++ b/pkg/util/qcloud/instance.go @@ -530,6 +530,9 @@ func (self *SRegion) StopVM(instanceId string, isForce bool) error { func (self *SRegion) DeleteVM(instanceId string) error { status, err := self.GetInstanceStatus(instanceId) if err != nil { + if err == cloudprovider.ErrNotFound { + return nil + } log.Errorf("Fail to get instance status on DeleteVM: %s", err) return err } @@ -582,18 +585,8 @@ func (self *SRegion) DeployVM(instanceId string, name string, password string, k } func (self *SInstance) DeleteVM() error { - for { - err := self.host.zone.region.DeleteVM(self.InstanceId) - if err != nil { - // if isError(err, "IncorrectInstanceStatus.Initializing") { - // log.Infof("The instance is initializing, try later ...") - // time.Sleep(10 * time.Second) - // } else { - // return err - // } - } else { - break - } + if err := self.host.zone.region.DeleteVM(self.InstanceId); err != nil { + return err } return cloudprovider.WaitDeleted(self, 10*time.Second, 300*time.Second) // 5minutes }