mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-07 06:02:09 +08:00
Automatic merge from release/2.8.0 -> master
* commit '43b09aae3dd341545745829593a15edfedf236d2': 避免部分公有云续费后过期时间更新慢问题导致平台未能设置正常的过期时间
This commit is contained in:
@@ -745,14 +745,19 @@ func (self *SManagedVirtualizedGuestDriver) RequestRenewInstance(guest *models.S
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
oldExpired := iVM.GetExpiredAt()
|
||||
err = iVM.Renew(bc)
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
err = iVM.Refresh()
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
//避免有些云续费后过期时间刷新比较慢问题
|
||||
cloudprovider.WaitCreated(15*time.Second, 5*time.Minute, func() bool {
|
||||
newExipred := iVM.GetExpiredAt()
|
||||
if newExipred.After(oldExpired) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
return iVM.GetExpiredAt(), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1114,14 +1114,6 @@ func (self *SRegion) DetachDisk(instanceId string, diskId string) error {
|
||||
// 只支持传入主资源ID, 根据“查询客户包周期资源列表”接口响应参数中的“is_main_resource”来标识。
|
||||
// expire_mode 0:进入宽限期 1:转按需 2:自动退订 3:自动续订(当前只支持ECS、EVS和VPC)
|
||||
func (self *SRegion) RenewInstance(instanceId string, bc billing.SBillingCycle) error {
|
||||
// 记录未续费前的过期时间
|
||||
ins, err := self.GetInstanceByID(instanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
oldExpired := ins.GetExpiredAt()
|
||||
|
||||
params := jsonutils.NewDict()
|
||||
res := jsonutils.NewArray()
|
||||
res.Add(jsonutils.NewString(instanceId))
|
||||
@@ -1138,7 +1130,7 @@ func (self *SRegion) RenewInstance(instanceId string, bc billing.SBillingCycle)
|
||||
params.Add(jsonutils.NewInt(PERIOD_TYPE_YEAR), "period_type")
|
||||
params.Add(jsonutils.NewInt(year), "period_num")
|
||||
} else {
|
||||
return fmt.Errorf("invalid renew period %s month,must be 1~11 month or 1~3 year", month)
|
||||
return fmt.Errorf("invalid renew period %d month,must be 1~11 month or 1~3 year", month)
|
||||
}
|
||||
|
||||
domainId, err := self.getDomianId()
|
||||
@@ -1152,19 +1144,7 @@ func (self *SRegion) RenewInstance(instanceId string, bc billing.SBillingCycle)
|
||||
}
|
||||
|
||||
_, err = self.ecsClient.Orders.RenewPeriodResource(params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 这里等待更新实例过期时间
|
||||
return cloudprovider.WaitCreated(15*time.Second, 180*time.Second, func() bool {
|
||||
newExipred := ins.GetExpiredAt()
|
||||
if newExipred.After(oldExpired) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/api-ecs/zh-cn_topic_0065817702.html
|
||||
|
||||
Reference in New Issue
Block a user