diff --git a/pkg/compute/models/groups.go b/pkg/compute/models/groups.go index da2db94d10..9d6d1f5e9d 100644 --- a/pkg/compute/models/groups.go +++ b/pkg/compute/models/groups.go @@ -415,7 +415,8 @@ func (group *SGroup) ClearAllScheDescCache() error { func (group *SGroup) clearSchedDescCache(hostIds []string) error { var g errgroup.Group - for _, hostId := range hostIds { + for i := range hostIds { + hostId := hostIds[i] g.Go(func() error { return HostManager.ClearSchedDescCache(hostId) }) diff --git a/pkg/compute/models/guest_sshable.go b/pkg/compute/models/guest_sshable.go index 3b00a53950..50cecb2b6f 100644 --- a/pkg/compute/models/guest_sshable.go +++ b/pkg/compute/models/guest_sshable.go @@ -519,9 +519,9 @@ func (guest *SGuest) GetDetailsMakeSshableCmd( } varVals := [][2]string{ - [2]string{"user", "cloudroot"}, - [2]string{"adminpub", strings.TrimSpace(adminPublicKey)}, - [2]string{"projpub", strings.TrimSpace(projectPublicKey)}, + {"user", "cloudroot"}, + {"adminpub", strings.TrimSpace(adminPublicKey)}, + {"projpub", strings.TrimSpace(projectPublicKey)}, } shellCmd := "" for i := range varVals { diff --git a/pkg/compute/regiondrivers/kvm.go b/pkg/compute/regiondrivers/kvm.go index b5f39ed63d..144fc501e0 100644 --- a/pkg/compute/regiondrivers/kvm.go +++ b/pkg/compute/regiondrivers/kvm.go @@ -1192,7 +1192,7 @@ func (self *SKVMRegionDriver) RequestPreSnapshotPolicyApply(ctx context.Context, } func (self *SKVMRegionDriver) ValidateCacheSecgroup(ctx context.Context, userCred mcclient.TokenCredential, secgroup *models.SSecurityGroup, vpc *models.SVpc, classic bool) error { - return fmt.Errorf("No need to cache secgroup for onecloud region") + return errors.Wrap(httperrors.ErrNotSupported, "No need to cache secgroup for onecloud region") } func (self *SKVMRegionDriver) ValidateCreateElasticcacheData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, input *api.ElasticcacheCreateInput) (*api.ElasticcacheCreateInput, error) { @@ -1397,6 +1397,9 @@ func (self *SKVMRegionDriver) RequestCreateBackup(ctx context.Context, backup *m func (self *SKVMRegionDriver) RequestAssociateEip(ctx context.Context, userCred mcclient.TokenCredential, eip *models.SElasticip, input api.ElasticipAssociateInput, obj db.IStatusStandaloneModel, task taskman.ITask) error { taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) { + if err := eip.AssociateInstance(ctx, userCred, input.InstanceType, obj); err != nil { + return nil, errors.Wrapf(err, "associate eip %s(%s) to %s %s(%s)", eip.Name, eip.Id, obj.Keyword(), obj.GetName(), obj.GetId()) + } switch input.InstanceType { case api.EIP_ASSOCIATE_TYPE_SERVER: err := self.requestAssociateEipWithServer(ctx, userCred, eip, input, obj, task) @@ -1416,11 +1419,8 @@ func (self *SKVMRegionDriver) RequestAssociateEip(ctx context.Context, userCred default: return nil, errors.Wrapf(cloudprovider.ErrNotSupported, "instance type %s", input.InstanceType) } - if err := eip.AssociateInstance(ctx, userCred, input.InstanceType, obj); err != nil { - return nil, errors.Wrapf(err, "associate eip %s(%s) to %s %s(%s)", eip.Name, eip.Id, obj.Keyword(), obj.GetName(), obj.GetId()) - } if err := eip.SetStatus(userCred, api.EIP_STATUS_READY, api.EIP_STATUS_ASSOCIATE); err != nil { - return nil, errors.Wrapf(err, "set eip status to %s", api.EIP_STATUS_ALLOCATE) + return nil, errors.Wrapf(err, "set eip status to %s", api.EIP_STATUS_READY) } return nil, nil })