diff --git a/pkg/compute/tasks/guest_syncstatus_task.go b/pkg/compute/tasks/guest_syncstatus_task.go index 790c2134baa..7f2c3b366c4 100644 --- a/pkg/compute/tasks/guest_syncstatus_task.go +++ b/pkg/compute/tasks/guest_syncstatus_task.go @@ -82,7 +82,9 @@ func (self *GuestSyncstatusTask) OnGetStatusComplete(ctx context.Context, obj db case api.VM_BLOCK_STREAM, api.VM_BLOCK_STREAM_FAIL: break default: - statusStr = api.VM_UNKNOWN + if guest.GetHypervisor() != api.HYPERVISOR_POD { + statusStr = api.VM_UNKNOWN + } } if !self.HasParentTask() { // migrating status hack diff --git a/pkg/hostman/guestman/pod.go b/pkg/hostman/guestman/pod.go index 88a4488b48c..021dea40d34 100644 --- a/pkg/hostman/guestman/pod.go +++ b/pkg/hostman/guestman/pod.go @@ -356,7 +356,11 @@ func (s *sPodGuestInstance) SyncStatus(reason string) { }, } if cs != nil { - ctrStatusInput.RestartCount = cs.RestartCount + if computeapi.ContainerRunningStatus.Has(cStatus) { + ctrStatusInput.RestartCount = 0 + } else { + ctrStatusInput.RestartCount = cs.RestartCount + } if !cs.StartedAt.IsZero() { ctrStatusInput.StartedAt = &cs.StartedAt } @@ -364,7 +368,7 @@ func (s *sPodGuestInstance) SyncStatus(reason string) { ctrStatusInput.LastFinishedAt = &cs.FinishedAt } if ctr := s.GetContainerById(c.Id); ctr != nil { - ctr.RestartCount = cs.RestartCount + ctr.RestartCount = ctrStatusInput.RestartCount ctr.StartedAt = cs.StartedAt ctr.LastFinishedAt = cs.FinishedAt if err := s.SaveContainerDesc(ctr); err != nil { @@ -1822,7 +1826,9 @@ func (s *sPodGuestInstance) getContainerStatus(ctx context.Context, ctrId string } } if status == computeapi.CONTAINER_STATUS_EXITED && resp.Status.ExitCode != 0 { - status = computeapi.CONTAINER_STATUS_CRASH_LOOP_BACK_OFF + if _, isInternalStopped := s.IsInternalStopped(criId); !isInternalStopped { + status = computeapi.CONTAINER_STATUS_CRASH_LOOP_BACK_OFF + } } return status, cs, nil }