cri: fix container status
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
This commit is contained in:
@@ -93,13 +93,23 @@ func toCRIContainerStatus(container containerstore.Container, spec *runtime.Imag
|
||||
}
|
||||
}
|
||||
|
||||
// If container is in the created state, not set started and finished unix timestamps
|
||||
var st, ft int64
|
||||
switch status.State() {
|
||||
case runtime.ContainerState_CONTAINER_RUNNING:
|
||||
// If container is in the running state, set started unix timestamps
|
||||
st = status.StartedAt
|
||||
case runtime.ContainerState_CONTAINER_EXITED, runtime.ContainerState_CONTAINER_UNKNOWN:
|
||||
st, ft = status.StartedAt, status.FinishedAt
|
||||
}
|
||||
|
||||
return &runtime.ContainerStatus{
|
||||
Id: meta.ID,
|
||||
Metadata: meta.Config.GetMetadata(),
|
||||
State: status.State(),
|
||||
CreatedAt: status.CreatedAt,
|
||||
StartedAt: status.StartedAt,
|
||||
FinishedAt: status.FinishedAt,
|
||||
StartedAt: st,
|
||||
FinishedAt: ft,
|
||||
ExitCode: status.ExitCode,
|
||||
Image: spec,
|
||||
ImageRef: imageRef,
|
||||
|
||||
Reference in New Issue
Block a user