mirror of
https://github.com/containers/podman.git
synced 2025-08-02 17:22:30 +08:00
remote: exec inspect update exec session status
The remote API will wait 300s by default before conmon will call the cleanup. In the meantime when you inspect an exec session started with ExecStart() (so not attached) and it did exit we do not know that. If a caller inspects it they think it is still running. To prevent this we should sync the session based on the exec pid and update the state accordingly. For a reproducer see the test in this commit or the issue. Fixes #18424 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -893,6 +893,17 @@ func (c *Container) execSessionNoCopy(id string) (*ExecSession, error) {
|
||||
return nil, fmt.Errorf("no exec session with ID %s found in container %s: %w", id, c.ID(), define.ErrNoSuchExecSession)
|
||||
}
|
||||
|
||||
// make sure to update the exec session if needed #18424
|
||||
alive, err := c.ociRuntime.ExecUpdateStatus(c, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !alive {
|
||||
if err := retrieveAndWriteExecExitCode(c, session.ID()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return session, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user