Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit adc0b6a

Browse files
authored
Merge pull request #1600 from zhuangqh/fix-unknown-state
[release/1.4 backport] fix: always set unknown to false when handling exit event
2 parents 9e81bf5 + 7973126 commit adc0b6a

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

pkg/server/events.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,11 @@ func handleContainerExit(ctx context.Context, e *eventtypes.TaskExit, cntr conta
325325
}
326326
}
327327
err = cntr.Status.UpdateSync(func(status containerstore.Status) (containerstore.Status, error) {
328-
// If FinishedAt has been set (e.g. with start failure), keep as
329-
// it is.
330-
if status.FinishedAt != 0 {
331-
return status, nil
328+
if status.FinishedAt == 0 {
329+
status.Pid = 0
330+
status.FinishedAt = e.ExitedAt.UnixNano()
331+
status.ExitCode = int32(e.ExitStatus)
332332
}
333-
status.Pid = 0
334-
status.FinishedAt = e.ExitedAt.UnixNano()
335-
status.ExitCode = int32(e.ExitStatus)
336333
// Unknown state can only transit to EXITED state, so we need
337334
// to handle unknown state here.
338335
if status.Unknown {

0 commit comments

Comments
 (0)