Skip to content

Commit

Permalink
fix(region,host): fix crash_loop_back_off status when container stopp…
Browse files Browse the repository at this point in the history
…ed (#21417)
  • Loading branch information
zexi authored Oct 16, 2024
1 parent a8a32fe commit 2f72980
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pkg/compute/tasks/guest_syncstatus_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions pkg/hostman/guestman/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,19 @@ 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
}
if !cs.FinishedAt.IsZero() {
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 {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 2f72980

Please sign in to comment.