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

skip setup signal notifier for detached container #4661

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lifubang
Copy link
Member

@lifubang lifubang commented Mar 5, 2025

For detached container, we don't need to setup signal notifier, because there is no customer to consume the signals in forward().

@lifubang lifubang force-pushed the skip-setup-signalNotify-for-detached branch from 9d4b664 to 08ab900 Compare March 5, 2025 14:38
For detached container, we don't need to setup signal notifier, because
there is no customer to consume the signals in `forward()`.

Signed-off-by: lifubang <lifubang@acmcoder.com>
@lifubang lifubang force-pushed the skip-setup-signalNotify-for-detached branch from 08ab900 to b2d5924 Compare March 5, 2025 14:39
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

Yeah, it's weird. We set up signal forwarding (for create/run/exec) and then we don't use it.

But, if notifySocker is non-nil, we set up signal forwarding and when we do forward signals for some short time (until we exit).

I can't review it because the current code makes no sense to me :(

@lifubang
Copy link
Member Author

lifubang commented Mar 6, 2025

But, if notifySocker is non-nil, we set up signal forwarding and when we do forward signals for some short time (until we exit).

I don’t think so, if notifySocket is non-nil, we also don’t consume any signals. There are two places checking detach in ‘forward()’:

  1. runc/signals.go

    Lines 73 to 75 in b2d5924

    if detach && h.notifySocket == nil {
    return 0, nil
    }
  2. runc/signals.go

    Lines 82 to 86 in b2d5924

    if h.notifySocket != nil {
    if detach {
    _ = h.notifySocket.run(pid1)
    return 0, nil
    }

The signal consumer is in:

for s := range h.signals {

If I miss something, please tell me.

@kolyshkin
Copy link
Contributor

Ah, yes, you are right, if detach is true, it exits either way. But the code around notifySocket is spaghetti (in a bad way).

Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM (yet I wish someone can refactor the code dealing with notifySocket, it seems it is orthogonal to signals and yet it is mixed together)

There are two paths about `detach` because we need to setup notify socket
once it is exist. It will cause the code too complex to read. So refactor
it to keep one path for detached container.

Signed-off-by: lifubang <lifubang@acmcoder.com>
@lifubang
Copy link
Member Author

lifubang commented Mar 7, 2025

yet I wish someone can refactor the code dealing with notifySocket, it seems it is orthogonal to signals and yet it is mixed together

Refactored. I think we should setup notify socket first before we handler and forward signals for non detached containers, so I didn't split them to two functions, but refactor to keep one path for detached container.
PTAL

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.

2 participants