Fix: Duplicate event on network disconnect#48800
Conversation
This fix resolves the issue where a network disconnect generates duplicate events. Co-authored-by: eyeamnoob <a.afraz.1380@gmail.com> Signed-off-by: AmirBuddy <badinlu.amirhossein@gmail.com> Signed-off-by: eyeamnoob <a.afraz.1380@gmail.com>
|
Thanks! Had a quick peek, and look like the other event may be coming from here; moby/daemon/container_operations.go Lines 916 to 928 in dc22579 As the other one is related to cluster (swarm) networks, we may have to double check if there's a codepath where we would now miss the event (to be sure). |
|
Thank you for the insight! I reviewed the
From these tests, it looks like the changes effectively remove the duplicate event issue in non-Swarm networks without impacting Swarm functionality. Please let me know if there’s anything else I may have missed that I should check. |
akerouanton
left a comment
There was a problem hiding this comment.
I think we should move the event sent by tryDetachContainerFromClusterNetwork up by one level (ie. into disconnectFromNetwork and releaseNetwork). But let's keep this for a follow-up pr. Thanks!
|
Don't merge yet; still want to have a peek as well; at least, want to look at the |
|
Thanks, @thaJeztah! I see the concern with |
There was a problem hiding this comment.
If DisconnectFromNetwork fails to find the network and force, or the container's not running ...
moby/daemon/container_operations.go
Lines 1020 to 1032 in 64ca1c0
disconnectFromNetwork -> tryDetachContainerFromClusterNetwork isn't called, so it won't send an event.
But, at the moment, the event will still be sent by DisconnectFromNetwork.
Sending an event for removal of a stopped container, or from a non-existent network, doesn't sound right. So, I think the change is good ... but, it is an extra change.
Sorry, that wasn't quite right - the event will only be sent for disconnect from a network that does exist (for a stopped container). |
|
@thaJeztah - final review :D |
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM
sorry, this one dropped of my radar, but looks like there's been enough eyes on this to make sure it's correct.
Thank you so much for contributing!
- What I did
I modified the
DisconnectFromNetworkfunction indaemon/container_operations.goto remove redundant code that was causing duplicate network disconnect events.- How I did it
By identifying and removing the part of the code that was generating an additional event when a network disconnection occurred.
- How to verify it
docker eventscommand to check that only onenetwork disconnectevent is generated for each disconnection.- Description for the changelog