mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-30 17:13:08 +08:00
fix: Fix problems about health check in auto scaling
1. Detach Guest with ScalingGroup 2. Health Check
This commit is contained in:
@@ -118,7 +118,7 @@ func (self *GuestDetachScalingGroupTask) OnDeleteGuestComplete(ctx context.Conte
|
||||
}
|
||||
|
||||
logclient.AddActionLogWithStartable(self, sg, logclient.ACT_REMOVE_GUEST, fmt.Sprintf("Instance '%s' was removed", guestId), self.UserCred, true)
|
||||
if auto, err := self.Params.Bool("auto"); err == nil || !auto {
|
||||
if auto, _ := self.Params.Bool("auto"); !auto {
|
||||
// scale; change the desire number
|
||||
err := sg.Scale(ctx, SScalingTriggerDesc{guestName}, SScalingActionDesc{})
|
||||
if err != nil {
|
||||
|
||||
@@ -44,7 +44,7 @@ func (asc *SASController) CheckInstanceHealth(ctx context.Context, userCred mccl
|
||||
checkEarliestTime := time.Now().Add(-10 * time.Minute)
|
||||
// Fetch all unhealth status instace
|
||||
unnormalGuests := make([]sUnnormalGuest, 0, 5)
|
||||
sgQ := models.ScalingGroupManager.Query("id").IsFalse("enabled").SubQuery()
|
||||
sgQ := models.ScalingGroupManager.Query("id").IsTrue("enabled").SubQuery()
|
||||
sggQ := models.ScalingGroupGuestManager.Query("guest_id", "scaling_group_id").In("scaling_group_id", sgQ).SubQuery()
|
||||
q := models.GuestManager.Query("id", "status").In("status", UnhealthStatus).LT("created_at", checkEarliestTime)
|
||||
q = q.Join(sggQ, sqlchemy.Equals(q.Field("id"), sggQ.Field("guest_id")))
|
||||
@@ -55,7 +55,7 @@ func (asc *SASController) CheckInstanceHealth(ctx context.Context, userCred mccl
|
||||
}
|
||||
for rows.Next() {
|
||||
var ug sUnnormalGuest
|
||||
rows.Scan(&ug)
|
||||
rows.Scan(&ug.Id, &ug.Status, &ug.ScalngGroupId)
|
||||
unnormalGuests = append(unnormalGuests, ug)
|
||||
}
|
||||
rows.Close()
|
||||
@@ -83,7 +83,7 @@ func (asc *SASController) CheckInstanceHealth(ctx context.Context, userCred mccl
|
||||
|
||||
if len(readyGuestList) > 0 {
|
||||
go func() {
|
||||
time.Sleep(3 * time.Minute)
|
||||
time.Sleep(2 * time.Minute)
|
||||
q := models.GuestManager.Query("id").In("id", readyGuestList).Equals("status", apis.VM_READY)
|
||||
rows, err := q.Rows()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user