mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Merge pull request #748 from wanyaoqi/bugfix/wyq/fix-syncstatus-stopping
bugfix: fix sync status on stoping
This commit is contained in:
@@ -396,7 +396,7 @@ func (self *GuestLiveMigrateTask) OnResumeDestGuestComplete(ctx context.Context,
|
||||
}
|
||||
|
||||
func (self *GuestLiveMigrateTask) OnUndeploySrcGuestComplete(ctx context.Context, guest *models.SGuest, data jsonutils.JSONObject) {
|
||||
db.OpsLog.LogEvent(guest, db.ACT_MIGRATE, "", self.UserCred)
|
||||
db.OpsLog.LogEvent(guest, db.ACT_MIGRATE, "OnUndeploySrcGuestComplete", self.UserCred)
|
||||
status, _ := self.Params.GetString("guest_status")
|
||||
if status != guest.Status {
|
||||
self.SetStage("OnGuestSyncStatus", nil)
|
||||
|
||||
@@ -351,12 +351,11 @@ func (m *SGuestManager) CpusetBalance(ctx context.Context, params interface{}) (
|
||||
}
|
||||
|
||||
func (m *SGuestManager) Status(sid string) string {
|
||||
if status := m.GetStatus(sid); status == GUEST_RUNNING && m.Servers[sid].Monitor == nil {
|
||||
status := m.GetStatus(sid)
|
||||
if status == GUEST_RUNNING && m.Servers[sid].Monitor == nil && !m.Servers[sid].IsStopping() {
|
||||
m.Servers[sid].StartMonitor(context.Background())
|
||||
return status
|
||||
} else {
|
||||
return status
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
func (m *SGuestManager) GetStatus(sid string) string {
|
||||
|
||||
@@ -61,6 +61,7 @@ func NewGuestStopTask(guest *SKVMGuestInstance, ctx context.Context, timeout int
|
||||
}
|
||||
|
||||
func (s *SGuestStopTask) Start() {
|
||||
s.stopping = true
|
||||
if s.IsRunning() && s.IsMonitorAlive() {
|
||||
s.Monitor.SimpleCommand("system_powerdown", s.onPowerdownGuest)
|
||||
} else {
|
||||
@@ -77,6 +78,7 @@ func (s *SGuestStopTask) onPowerdownGuest(results string) {
|
||||
func (s *SGuestStopTask) checkGuestRunning() {
|
||||
if !s.IsRunning() || time.Now().Sub(s.startPowerdown) > time.Duration(s.timeout)*time.Second {
|
||||
s.Stop() // force stop
|
||||
s.stopping = false
|
||||
hostutils.TaskComplete(s.ctx, nil)
|
||||
} else {
|
||||
s.CheckGuestRunningLater()
|
||||
|
||||
@@ -68,6 +68,7 @@ type SKVMGuestInstance struct {
|
||||
manager *SGuestManager
|
||||
|
||||
startupTask *SGuestResumeTask
|
||||
stopping bool
|
||||
}
|
||||
|
||||
func NewKVMGuestInstance(id string, manager *SGuestManager) *SKVMGuestInstance {
|
||||
@@ -77,6 +78,10 @@ func NewKVMGuestInstance(id string, manager *SGuestManager) *SKVMGuestInstance {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) IsStopping() bool {
|
||||
return s.stopping
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) GetId() string {
|
||||
id, _ := s.Desc.GetString("uuid")
|
||||
return id
|
||||
|
||||
Reference in New Issue
Block a user