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

cmd/docker: add cause to user-terminated context.Context #5760

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Benehiko
Copy link
Member

This patch adds a "cause" to the context.Context error when the user terminates the process through SIGINT/SIGTERM.

This allows us to distinguish the cause of the
context.Context cancellation. In future we would also be able to improve the UX of printed errors
based on the underlying cause.

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

This patch adds a "cause" to the `context.Context`
error when the user terminates the process through
SIGINT/SIGTERM.

This allows us to distinguish the cause of the
`context.Context` cancellation. In future we would
also be able to improve the UX of printed errors
based on the underlying cause.

Signed-off-by: Alano Terblanche <[email protected]>
@Benehiko Benehiko requested a review from a team January 20, 2025 11:06
@codecov-commenter
Copy link

codecov-commenter commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 58.82353% with 14 lines in your changes missing coverage. Please review.

Project coverage is 59.42%. Comparing base (f97ec69) to head (da5701e).
Report is 21 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5760      +/-   ##
==========================================
- Coverage   59.47%   59.42%   -0.05%     
==========================================
  Files         346      347       +1     
  Lines       29367    29433      +66     
==========================================
+ Hits        17465    17491      +26     
- Misses      10929    10969      +40     
  Partials      973      973              

cmd/docker/docker.go Show resolved Hide resolved
cmd/docker/docker.go Show resolved Hide resolved
@Benehiko Benehiko requested review from ndeloof and glours January 21, 2025 14:35
fayazkhan121

This comment was marked as spam.

Signed-off-by: Alano Terblanche <[email protected]>
@Benehiko Benehiko force-pushed the user-terminated-ctx-err branch from 8839f12 to bdd630c Compare January 24, 2025 15:32
Copy link

@fayazkhan121 fayazkhan121 left a comment

Choose a reason for hiding this comment

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

The test looks solid. TestUserTerminatedError test case properly introduces notifyContext and handles the termination signals as expected.

@Benehiko
Copy link
Member Author

Please don't merge yet, this is incorrect. We need to have status 130 print when a container exits with that code.

@Benehiko Benehiko force-pushed the user-terminated-ctx-err branch from da5701e to bdd630c Compare January 31, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants