mirror of
https://github.com/containers/podman.git
synced 2025-06-23 18:59:30 +08:00
Merge pull request #12394 from flouthoc/oci_dont_send_signal_to_dead
oci: exit `gracefully` if container is already dead instead of trying to `kill` it.
This commit is contained in:
@ -297,7 +297,7 @@ func (r *ConmonOCIRuntime) UpdateContainerStatus(ctr *Container) error {
|
|||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
return errors.Wrapf(err, "error getting container %s state", ctr.ID())
|
return errors.Wrapf(err, "error getting container %s state", ctr.ID())
|
||||||
}
|
}
|
||||||
if strings.Contains(string(out), "does not exist") {
|
if strings.Contains(string(out), "does not exist") || strings.Contains(string(out), "No such file") {
|
||||||
if err := ctr.removeConmonFiles(); err != nil {
|
if err := ctr.removeConmonFiles(); err != nil {
|
||||||
logrus.Debugf("unable to remove conmon files for container %s", ctr.ID())
|
logrus.Debugf("unable to remove conmon files for container %s", ctr.ID())
|
||||||
}
|
}
|
||||||
@ -407,6 +407,11 @@ func (r *ConmonOCIRuntime) KillContainer(ctr *Container, signal uint, all bool)
|
|||||||
args = append(args, "kill", ctr.ID(), fmt.Sprintf("%d", signal))
|
args = append(args, "kill", ctr.ID(), fmt.Sprintf("%d", signal))
|
||||||
}
|
}
|
||||||
if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, env, r.path, args...); err != nil {
|
if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, env, r.path, args...); err != nil {
|
||||||
|
// try updating container state but ignore errors we cant do anything if this fails.
|
||||||
|
r.UpdateContainerStatus(ctr)
|
||||||
|
if ctr.state.State == define.ContainerStateExited {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return errors.Wrapf(err, "error sending signal to container %s", ctr.ID())
|
return errors.Wrapf(err, "error sending signal to container %s", ctr.ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user