From c405047eca637739c8665d28b47810d7d7e41f36 Mon Sep 17 00:00:00 2001 From: TangBin Date: Thu, 14 Nov 2019 18:35:07 +0800 Subject: [PATCH] huawei config vm config fix --- pkg/compute/guestdrivers/managedvirtual.go | 14 ++++++-------- pkg/multicloud/huawei/instance.go | 12 ++++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/pkg/compute/guestdrivers/managedvirtual.go b/pkg/compute/guestdrivers/managedvirtual.go index d3284add1b..9ea3b38c67 100644 --- a/pkg/compute/guestdrivers/managedvirtual.go +++ b/pkg/compute/guestdrivers/managedvirtual.go @@ -20,11 +20,9 @@ import ( "math" "time" - "github.com/pkg/errors" - "yunion.io/x/jsonutils" "yunion.io/x/log" - errors2 "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/errors" billing_api "yunion.io/x/onecloud/pkg/apis/billing" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -362,7 +360,7 @@ func (self *SManagedVirtualizedGuestDriver) RequestDeployGuestOnHost(ctx context } if sku == nil { - return errors.Wrap(errors2.ErrNotFound, "ManagedVirtualizedGuestDriver.RequestDeployGuestOnHost.GetMatchedSku") + return errors.Wrap(errors.ErrNotFound, "ManagedVirtualizedGuestDriver.RequestDeployGuestOnHost.GetMatchedSku") } desc.InstanceType = sku.Name @@ -741,7 +739,7 @@ func (self *SManagedVirtualizedGuestDriver) RequestChangeVmConfig(ctx context.Co } if sku == nil { - return errors.Wrap(errors2.ErrNotFound, "ManagedVirtualizedGuestDriver.RequestChangeVmConfig.GetMatchedSku") + return errors.Wrap(errors.ErrNotFound, "ManagedVirtualizedGuestDriver.RequestChangeVmConfig.GetMatchedSku") } instanceType = sku.Name @@ -755,7 +753,7 @@ func (self *SManagedVirtualizedGuestDriver) RequestChangeVmConfig(ctx context.Co } err := iVM.ChangeConfig(ctx, config) if err != nil { - return nil, err + return nil, errors.Wrap(err, "GuestDriver.RequestChangeVmConfig.ChangeConfig") } err = cloudprovider.WaitCreated(time.Second*5, time.Minute*5, func() bool { @@ -778,7 +776,7 @@ func (self *SManagedVirtualizedGuestDriver) RequestChangeVmConfig(ctx context.Co return false }) if err != nil { - return nil, err + return nil, errors.Wrap(err, "GuestDriver.RequestChangeVmConfig.WaitCreated") } instanceType = iVM.GetInstanceType() @@ -788,7 +786,7 @@ func (self *SManagedVirtualizedGuestDriver) RequestChangeVmConfig(ctx context.Co return nil }) if err != nil { - return nil, err + return nil, errors.Wrap(err, "GuestDriver.RequestChangeVmConfig.Update") } } diff --git a/pkg/multicloud/huawei/instance.go b/pkg/multicloud/huawei/instance.go index 476550a047..913a193860 100644 --- a/pkg/multicloud/huawei/instance.go +++ b/pkg/multicloud/huawei/instance.go @@ -22,10 +22,9 @@ import ( "strings" "time" - "github.com/pkg/errors" - "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/osprofile" "yunion.io/x/pkg/utils" @@ -590,10 +589,15 @@ func (self *SInstance) ChangeConfig(ctx context.Context, config *cloudprovider.S func (self *SInstance) ChangeConfig2(ctx context.Context, instanceType string) error { err := self.host.zone.region.ChangeVMConfig2(self.OSEXTAZAvailabilityZone, self.GetId(), instanceType, nil) if err != nil { - return err + return errors.Wrap(err, "Instance.ChangeConfig2.ChangeVMConfig2") } - return cloudprovider.WaitStatusWithDelay(self, api.VM_READY, 15*time.Second, 15*time.Second, 180*time.Second) + err = cloudprovider.WaitStatusWithDelay(self, api.VM_READY, 15*time.Second, 15*time.Second, 180*time.Second) + if err != nil { + return errors.Wrap(err, "Instance.ChangeConfig2.WaitStatusWithDelay") + } + + return nil } // todo:// 返回jsonobject感觉很诡异。不能直接知道内部细节