Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make kill noop on second run #1269

Merged

Conversation

gabriel-samfira
Copy link
Contributor

If a kill has already been delivered, make the Kill() function a no-op, and simply return previous status. The documentation of TerminateProcess states that a process cannot prevent itself from being terminated. That means that once we successfully deliver a kill signal, there is no real justification to send a second one.

Additionally, we also ignore two errors that are potentially returned by HcsTerminateProcess.

A bit of background on this. We've noticed during testing, that sending multiple Kill() signals to a process will sometimes return one of two (maybe more?) errors:

  • Access is denied (returned by TerminateProcess)
  • The process has already exited (returned by HCS)

In both cases, an error is returned signaling that the desired state reflects the current state of the process. These two errors should be ignored by Kill(), as there is no real reason to bubble them up the stack and have these errors handled by the called of Kill().

We want to both ignore a second call to Kill() and ignore these two errors, as processes started by containers bay be killed by external actors (human operator, an automated process, OOM, etc).

@gabriel-samfira gabriel-samfira requested a review from a team as a code owner January 7, 2022 21:58
If a kill has already been delivered, ignore subsequent calls to
Kill() and simply return the previous status.

This change also defines ErrProcessAlreadyStopped and ignores that
error if encountered during kill.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Copy link
Contributor

@anmaxvl anmaxvl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dcantah dcantah merged commit a460152 into microsoft:master Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants