-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 nil stop value for source.Channel #154
Conversation
fixes kubernetes-sigs#103 Creates a stop channel for the manager in New(), which will get passed to any source.Channel instances that are added. When the manager's start method is called and a new stop channel is passed in, that channel will be joined in a goroutine with the manager's existing channel so that if the newer channel gets closed, so will the manager's.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhrivnak If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
I signed it. |
I've had a look at this this morning and I think it rather overcomplicates the changes required. I don't think you need to create the second I put together a quick attempt that I think suffices and changes less of the existing code, I don't know if that would be preferred or not but I think the test cases I've added cover the behaviour that we are looking for here? |
Thanks for the feedback. I started out with roughly what you posted. I added some additional changes, which may not strictly be necessary, for these reasons:
@JoelSpeed let me know what you think of all that. I'm certainly flexible, and my main goal is just to get the bug fixed. |
sorry, coming late to the party. Thanks for the detailed comments above. I want to explore the possibility of passing in the This raises the question about the stop channel being passed to |
I completely agree. That would be the best design, to just pass one stop channel to the manager's constructor and be done. As I understand it, the main reason not to do that would be backward compatibility with |
Yes, backward compatibility is the main issue. Couple of options come to mind:
Open to other ideas as well. |
If you did this you would still need this code or something like it to handle the case where the user passes a stop channel into start even if it is deprecated right? |
We'll already need a "major" (0.Y) release this release due to non-backwards-compat changes, so it's less backwards compat, and more consistency, but if we can get a better design, we should do it now before we hit 1.0, while we're already shaking things up a bit. |
That said, passing and lazily initializing the stop channel ahead of time could be a decent design. If we work it right, we could even get rid of the necessity of manually calling the signal handler setup code, which is a bit ugly, IMO. |
Agreed with both points. We can do the prep-work for 0.1.x branch next week, but in the meantime, @mhrivnak @shawn-hurley are you guys interested in vetting the proposed changes in PR (with assumption of making a breaking change) to see if it works ? |
Happy to help. Just to make sure I'm clear, are you asking if we want to make a new PR that tries out the breaking change approach? Happy to do so. |
Thanks. Yes, thats the intention here. |
I'll have another PR to look at shortly that makes backward-incompatible changes, but in the mean time I revised this one. Having looked more closely at how |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor naming related nits to make the code a bit easier to follow, otherwise LGTM
@@ -75,6 +75,9 @@ type controllerManager struct { | |||
errChan chan error | |||
stop <-chan struct{} | |||
|
|||
// stopper is the write side of the stop channel. They should have the same value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe change to (for a bit more clarity -- it took me a moment to parse what "they" was):
stopper is the write side of the stop channel. It and
stop
should have the same value.
select { | ||
// Only this function should receive from stop, and everything else | ||
// should receive from cm.stop. | ||
case <-stop: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this flow gets a bit confusing to read with cm.stop
vs stop
. Maybe stop
to externalStop
or rename cm.stop
to cm.internalStop
.
if cm.resourceLock == nil { | ||
go cm.start(stop) | ||
go cm.start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this doesn't block. Does it really need a goroutine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go cm.start() | |
cm.start() |
Ping. Can we get this in? |
@@ -75,6 +75,9 @@ type controllerManager struct { | |||
errChan chan error | |||
stop <-chan struct{} | |||
|
|||
// stopper is the write side of the stop channel. They should have the same value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// stopper is the write side of the stop channel. They should have the same value. | |
// stopper is the write side of the stop channel (used to close `stop`). It and `stop` should have the same value. |
if cm.resourceLock == nil { | ||
go cm.start(stop) | ||
go cm.start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go cm.start() | |
cm.start() |
/assign @DirectXMan12 |
I'm going to fix this up and get it merged to unblock people. Thanks for your contribution, @mhrivnak ! |
Ok, thanks! I'm about a week away from having time to come back to it, so I appreciate the help. I'll be on the lookout to review it. |
Superseded by #204 |
fixes #103
Creates a stop channel for the manager in New(), which will get passed to any
source.Channel instances that are added. When the manager's start method is
called and a new stop channel is passed in, that channel will be joined in a
goroutine with the manager's existing channel so that if the newer channel gets
closed, so will the manager's.