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

Remove ERROR_PROC_NOT_FOUND from error checks #1064

Merged
merged 1 commit into from
Jul 8, 2021

Conversation

kevpar
Copy link
Member

@kevpar kevpar commented Jul 7, 2021

Previously, certain error check functions like IsAlreadyStopped returned
true if the error was ERROR_PROC_NOT_FOUND. Based on the comment in the
file, this was intended to be used to indicate a case where the process
could not be found. However, it seems this may have been added
erroneously. ERROR_PROC_NOT_FOUND is actually typically used to mean
that a procedure lookup failed, and has nothing to do with processes.

The original change[1] to check against ERROR_PROC_NOT_FOUND was made
five years ago, and did not contain much information on why this error
would be returned. We are removing this now based on several factors:

  • We are not aware of any condition where HCS would intentionally return
    ERROR_PROC_NOT_FOUND to indicate a condition "process does not exist".
  • There is an issue where HcsShutdownComputeSystem sometimes returns
    ERROR_PROC_NOT_FOUND due to something failing internally. The current
    error checks are causing this to be treated as "the container has
    already exited", causing moby to not properly stop the container via
    HcsTerminateComputeSystem.

This change leaves the definition for ErrProcNotFound in the code, as it
may be used by external callers, but fixes its comment.

[1]: See commit 0ae7e7e

Signed-off-by: Kevin Parsons kevpar@microsoft.com

Previously, certain error check functions like IsAlreadyStopped returned
true if the error was ERROR_PROC_NOT_FOUND. Based on the comment in the
file, this was intended to be used to indicate a case where the process
could not be found. However, it seems this may have been added
erroneously. ERROR_PROC_NOT_FOUND is actually typically used to mean
that a _procedure_ lookup failed, and has nothing to do with processes.

The original change[1] to check against ERROR_PROC_NOT_FOUND was made
five years ago, and did not contain much information on why this error
would be returned. We are removing this now based on several factors:

- We are not aware of any condition where HCS would intentionally return
  ERROR_PROC_NOT_FOUND to indicate a condition "process does not exist".
- There is an issue where HcsShutdownComputeSystem sometimes returns
  ERROR_PROC_NOT_FOUND due to something failing internally. The current
  error checks are causing this to be treated as "the container has
  already exited", causing moby to not properly stop the container via
  HcsTerminateComputeSystem.

This change leaves the definition for ErrProcNotFound in the code, as it
may be used by external callers, but fixes its comment.

[1]: See commit 0ae7e7e

Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
@kevpar kevpar requested a review from a team as a code owner July 7, 2021 23:27
@dcantah
Copy link
Contributor

dcantah commented Jul 8, 2021

@kevpar
Copy link
Member Author

kevpar commented Jul 8, 2021

@kevpar Is this where the moby culprit is I gather? https://github.com/moby/moby/blob/b57e71941eaedcd163fd0f73bfad5dc2f8cf4986/libcontainerd/local/local_windows.go#L1072

That's correct. If IsAlreadyStopped returns true then they skip calling terminate.

@dcantah
Copy link
Contributor

dcantah commented Jul 8, 2021

Awesome find (might have already said this) 😄

Copy link
Contributor

@katiewasnothere katiewasnothere left a comment

Choose a reason for hiding this comment

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

fun stuff, lgtm

@jsturtevant
Copy link
Contributor

@AbelHu fyi

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.

4 participants