mirror of
https://github.com/containers/podman.git
synced 2025-06-25 03:52:15 +08:00
Merge pull request #18437 from Luap99/exec-inspect-remote
remote: exec inspect update exec session status
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
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ var _ = Describe("Podman containers exec", func() {
|
||||
bt.cleanup()
|
||||
})
|
||||
|
||||
It("Podman exec create makes an exec session", func() {
|
||||
It("Podman exec create+start makes an exec session", func() {
|
||||
name := "testCtr"
|
||||
cid, err := bt.RunTopContainer(&name, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@ -48,6 +48,15 @@ var _ = Describe("Podman containers exec", func() {
|
||||
Expect(inspectOut.ProcessConfig.Entrypoint).To(Equal("echo"))
|
||||
Expect(inspectOut.ProcessConfig.Arguments).To(HaveLen(1))
|
||||
Expect(inspectOut.ProcessConfig.Arguments[0]).To(Equal("hello world"))
|
||||
|
||||
err = containers.ExecStart(bt.conn, sessionID, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
inspectOut, err = containers.ExecInspect(bt.conn, sessionID, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(inspectOut.ContainerID).To(Equal(cid))
|
||||
Expect(inspectOut.Running).To(BeFalse(), "session should not be running")
|
||||
Expect(inspectOut.ExitCode).To(Equal(0), "exit code from echo")
|
||||
})
|
||||
|
||||
It("Podman exec create with bad command fails", func() {
|
||||
|
Reference in New Issue
Block a user