-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
identity: cache: close channel in writing party #25353
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,9 @@ type CachingIdentityAllocator struct { | |
|
||
identitiesPath string | ||
|
||
// This field exists is to hand out references that are either for sending | ||
// and receiving. It should not be used directly without converting it first | ||
// to a AllocatorEventSendChan or AllocatorEventRecvChan. | ||
events allocator.AllocatorEventChan | ||
watcher identityWatcher | ||
|
||
|
@@ -167,7 +170,7 @@ func (m *CachingIdentityAllocator) InitIdentityAllocator(client clientset.Interf | |
|
||
// Asynchronously set up the global identity allocator since it connects | ||
// to the kvstore. | ||
go func(owner IdentityAllocatorOwner, events allocator.AllocatorEventChan, minID, maxID idpool.ID) { | ||
go func(owner IdentityAllocatorOwner, events allocator.AllocatorEventSendChan, minID, maxID idpool.ID) { | ||
m.setupMutex.Lock() | ||
defer m.setupMutex.Unlock() | ||
|
||
|
@@ -273,7 +276,9 @@ func (m *CachingIdentityAllocator) Close() { | |
|
||
m.IdentityAllocator.Delete() | ||
if m.events != nil { | ||
close(m.events) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Since we don't close You might will to change the signature of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm this is actually a bit more involved than I though - looking into other uses of that type. |
||
// Have the now only remaining writing party close the events channel, | ||
// to ensure we don't panic with 'send on closed channel'. | ||
Comment on lines
+279
to
+280
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not confident that this statement is guaranteed to be true in a clustermesh scenario. The events channel is also propagated to remote watchers, which might still be running when the main allocator is closed (the clustermesh subsystem is never stopped on shutdown). Likely not a big deal though, since that should be extremely rare and we are already shutting down. For this reason I wonder if it is something actually worth solving it in this PR (it might be quite complex to fix). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, you're right, that's still broken. It's kind of unclear to me what the ownership relations are in the clustermesh scenario. Does a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently the cache corresponding to a given remote cluster is closed here, which happens when the associated cluster configuration is removed, but is not triggered when the agent is shut down. The two possible alternatives seem to be either ensuring that the clustermesh subsystem is stopped before the allocator is closed, or making sure that
I would tend to say so, since a remote cache is pointless to exist without the main allocator (but their lifecycle is currently managed externally). |
||
m.localIdentities.close() | ||
m.events = nil | ||
} | ||
|
||
|
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.