From 6e1b5ceae7ce537e0dfe4c46323a7cb202d5b722 Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Tue, 25 Feb 2020 15:49:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=94=E5=9B=9Eazure=20api=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/multicloud/azure/instance.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/multicloud/azure/instance.go b/pkg/multicloud/azure/instance.go index 1b5b96ff4a..c50e859b54 100644 --- a/pkg/multicloud/azure/instance.go +++ b/pkg/multicloud/azure/instance.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/osprofile" billing_api "yunion.io/x/onecloud/pkg/apis/billing" @@ -611,19 +612,21 @@ func (self *SInstance) ChangeConfig(ctx context.Context, config *cloudprovider.S if len(config.InstanceType) > 0 { return self.ChangeConfig2(ctx, config.InstanceType) } + var err error status := self.GetStatus() for _, vmSize := range self.host.zone.region.getHardwareProfile(config.Cpu, config.MemoryMB) { self.Properties.HardwareProfile.VMSize = vmSize self.Properties.ProvisioningState = "" self.Properties.InstanceView = nil log.Debugf("Try HardwareProfile : %s", vmSize) - err := self.host.zone.region.client.Update(jsonutils.Marshal(self), nil) + err = self.host.zone.region.client.Update(jsonutils.Marshal(self), nil) if err == nil { return cloudprovider.WaitStatus(self, status, 10*time.Second, 300*time.Second) - } else { - log.Debugf("ChangeConfig %s", err) } } + if err != nil { + return errors.Wrap(err, "client.Update") + } return fmt.Errorf("Failed to change vm config, specification not supported") } @@ -634,13 +637,10 @@ func (self *SInstance) ChangeConfig2(ctx context.Context, instanceType string) e self.Properties.InstanceView = nil log.Debugf("Try HardwareProfile : %s", instanceType) err := self.host.zone.region.client.Update(jsonutils.Marshal(self), nil) - if err == nil { - return cloudprovider.WaitStatus(self, status, 10*time.Second, 300*time.Second) - } else { - log.Errorf("ChangeConfig2 %s", err) + if err != nil { + return errors.Wrap(err, "client.Update") } - - return fmt.Errorf("Failed to change vm config, specification not supported") + return cloudprovider.WaitStatus(self, status, 10*time.Second, 300*time.Second) } func (region *SRegion) ChangeVMConfig2(ctx context.Context, instanceId string, instanceType string) error {