-
Notifications
You must be signed in to change notification settings - Fork 616
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
fix panic in portallocator and deallocate endpoints when update with none EndpointSpec #1481
Conversation
Current coverage is 55.40% (diff: 28.57%)@@ master #1481 diff @@
==========================================
Files 82 82
Lines 12914 12920 +6
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 7173 7158 -15
- Misses 4757 4771 +14
- Partials 984 991 +7
|
Ooo, ouch. Good catch. LGTM. As an aside, can you reproduce this behavior? I'm wondering how a panic went this long without being noticed. |
Actually I can not reproduce this issue 100%. My colleague sent me the log. I just read the code and try to fix this. @dperny |
This doesn't look right. If Spec is nil, then it seems we have no allocation to do, so it should return true. @mrjana Also, let's make sure there is a unit test for this. |
PortAllocator is little different since it may always need to reconcile the spec with the actual But the current crash can happen only if there was non-nil Even for the case of |
In order to reproduce, create a service specifying a plublish port. Your change fixes the panic, but I am wondering whether we should instead reject a request where Also the cli allows to add or remove one exposed port at the time, and the cli client takes care of passing the proper list of ports. [Note] Did not see @mrjana's reply when sent this one. |
I'd prefer not to do this. I think it's better to be more flexible in what we allow. If we always require an |
@aaronlehmann I agree with you. In case a service had multiple published ports and an update with no spec is received, if the allocator cannot remove all at once (my guess given the cli provides flags to only remove one port at the time), either it should return a proper error or be changed to autonomously remove all the ports one by one. |
@aboch @aaronlehmann I agree with @aaronlehmann. We should handle an update to BTW, even with CLI I believe you can remove all ports at once by providing multiple --publish-rm options. |
This is simply the right fix. A |
I wrote a test case to reproduce the panic:
|
@dperny @stevvooe @mrjana @aaronlehmann @yongtang @aboch |
@allencloud You can continue with this PR, starting by integrating the unit test suggested by @yongtang. The fix should be straightforward, involving a little bit of work to ensure that the deallocations happen. |
f44b2d8
to
bf851cf
Compare
PR updated, PTAL. |
@allencloud Should be trivial to convert the testcase to swarmkit. If you need help, let me know. |
…on-endpointSpec Signed-off-by: allencloud <allen.sun@daocloud.io>
bf851cf
to
33ce23b
Compare
@stevvooe
And the modified PTAL |
any update? |
LGTM |
1 similar comment
LGTM |
fixes #1480
This PR did:
Signed-off-by: allencloud allen.sun@daocloud.io