mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-31 01:35:56 +08:00
fix(region): Fix problems for Auto Scaling
1. 支持 scaling group 根据 enable 过滤 2. 周期策略返回开始时间 3. scaling controller 在创建机器之前先调用 scheduler 的 forcast 接口 4. 修复健康状态检查的一个问题
This commit is contained in:
@@ -95,6 +95,13 @@ func (spm *SScalingPolicyManager) ListItemFilter(ctx context.Context, q *sqlchem
|
||||
return q, err
|
||||
}
|
||||
q, err = spm.SScalingGroupResourceBaseManager.ListItemFilter(ctx, q, userCred, input.ScalingGroupFilterListInput)
|
||||
if err != nil {
|
||||
return q, err
|
||||
}
|
||||
q, err = spm.SEnabledResourceBaseManager.ListItemFilter(ctx, q, userCred, input.EnabledResourceBaseListInput)
|
||||
if err != nil {
|
||||
return q, err
|
||||
}
|
||||
if len(input.TriggerType) != 0 {
|
||||
q = q.Equals("trigger_type", input.TriggerType)
|
||||
}
|
||||
|
||||
@@ -276,6 +276,7 @@ func (st *SScalingTimer) CycleTimerDetails() api.ScalingCycleTimerDetails {
|
||||
Hour: st.Hour,
|
||||
WeekDays: st.GetWeekDays(),
|
||||
MonthDays: st.GetMonthDays(),
|
||||
StartTime: st.StartTime,
|
||||
EndTime: st.EndTime,
|
||||
CycleType: st.Type,
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/util/httputils"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
)
|
||||
|
||||
@@ -406,10 +407,21 @@ func (asc *SASController) findSuitableInstance(sg *models.SScalingGroup, num int
|
||||
|
||||
func (asc *SASController) createInstances(session *mcclient.ClientSession, params jsonutils.JSONObject, count int,
|
||||
failedList []string, succeedList []SInstance) ([]string, []SInstance) {
|
||||
// forcast first
|
||||
dict := params.(*jsonutils.JSONDict)
|
||||
dict.Set("count", jsonutils.NewInt(int64(count)))
|
||||
_, err := modules.SchedManager.DoForecast(session, dict)
|
||||
if err != nil {
|
||||
clientErr := err.(*httputils.JSONClientError)
|
||||
failedList = append(failedList, clientErr.Details)
|
||||
}
|
||||
dict.Remove("count")
|
||||
|
||||
if count == 1 {
|
||||
ret, err := modules.Servers.Create(session, params)
|
||||
if err != nil {
|
||||
failedList = append(failedList, err.Error())
|
||||
clientErr := err.(*httputils.JSONClientError)
|
||||
failedList = append(failedList, clientErr.Details)
|
||||
return failedList, succeedList
|
||||
}
|
||||
id, _ := ret.GetString("id")
|
||||
|
||||
@@ -106,7 +106,7 @@ func (asc *SASController) CheckInstanceHealth(ctx context.Context, userCred mccl
|
||||
session := auth.GetSession(ctx, userCred, "", "")
|
||||
for i := range unnormalGuests {
|
||||
ug := unnormalGuests[i]
|
||||
if ug.CreateCompleteTime.Add(time.Duration(scalingGroupMap[ug.Id].HealthCheckGov) * time.Second).After(now) {
|
||||
if ug.CreateCompleteTime.Add(time.Duration(scalingGroupMap[ug.ScalngGroupId].HealthCheckGov) * time.Second).After(now) {
|
||||
continue
|
||||
}
|
||||
if ug.Status == apis.VM_READY {
|
||||
|
||||
Reference in New Issue
Block a user