Skip to content

Commit

Permalink
Merge pull request #12394 from flouthoc/oci_dont_send_signal_to_dead
Browse files Browse the repository at this point in the history
oci: exit `gracefully` if container is already dead instead of trying to `kill` it.
  • Loading branch information
openshift-merge-robot authored Nov 23, 2021
2 parents 3a19cdc + a4e4b8d commit 9e07cb1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libpod/oci_conmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (r *ConmonOCIRuntime) UpdateContainerStatus(ctr *Container) error {
if err2 != nil {
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 {
logrus.Debugf("unable to remove conmon files for container %s", ctr.ID())
}
Expand Down Expand Up @@ -407,6 +407,11 @@ func (r *ConmonOCIRuntime) KillContainer(ctr *Container, signal uint, all bool)
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 {
// 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())
}

Expand Down

0 comments on commit 9e07cb1

Please sign in to comment.