mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Merge pull request #6102 from rainzm/automated-cherry-pick-of-#6101-upstream-release-3.2
Automated cherry pick of #6101: fix/autoscaling: Chang the format of CoolingTime
This commit is contained in:
@@ -493,6 +493,8 @@ func (sg *SScalingGroup) exec(ctx context.Context, action IScalingAction) (ret s
|
||||
return
|
||||
}
|
||||
|
||||
var CoolingTimeLocation, _ = time.LoadLocation("Asia/Shanghai")
|
||||
|
||||
// Scale will modify SScalingGroup.DesireInstanceNumber and generate SScalingActivity based on the trigger and its
|
||||
// corresponding SScalingPolicy.
|
||||
func (sg *SScalingGroup) Scale(ctx context.Context, triggerDesc IScalingTriggerDesc, action IScalingAction,
|
||||
@@ -514,7 +516,8 @@ func (sg *SScalingGroup) Scale(ctx context.Context, triggerDesc IScalingTriggerD
|
||||
}
|
||||
if action.CheckCoolTime() && !sg.AllowScale() {
|
||||
err = scalingActivity.SetReject("",
|
||||
fmt.Sprintf("The Cooling Time limit the execution time of the policy to at least: %s", sg.AllowScaleTime.Format("2006-01-02 15:04:05")))
|
||||
fmt.Sprintf("The Cooling Time limit the execution time of the policy to at least: %s",
|
||||
sg.AllowScaleTime.In(CoolingTimeLocation).Format("2006-01-02 15:04:05 -0700")))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -239,6 +239,17 @@ func (spm *SScalingPolicyManager) ValidateCreateData(ctx context.Context, userCr
|
||||
return input, err
|
||||
}
|
||||
|
||||
func (sp *SScalingPolicy) CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential,
|
||||
ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
|
||||
// sp.Project must be same with sp.ScalingGroup
|
||||
sg, err := sp.ScalingGroup()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ownerId = sg.GetOwnerId()
|
||||
return sp.SVirtualResourceBase.CustomizeCreate(ctx, userCred, ownerId, query, data)
|
||||
}
|
||||
|
||||
func (sp *SScalingPolicy) Delete(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
// do nothing
|
||||
sp.SetStatus(userCred, api.SP_STATUS_DELETING, "")
|
||||
|
||||
Reference in New Issue
Block a user