-
Notifications
You must be signed in to change notification settings - Fork 208
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
Use Factory for informers #412
Conversation
go func() { | ||
<-ei.ctx.Done() | ||
ei.stopped = true | ||
close(stopCh) | ||
DefaultFactoryStore.Stop(ei.FactoryIndex) | ||
}() | ||
|
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.
This go routine (also ctx field) seems redundant after changes in 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.
I thought that this is still required 🙈 Could you please point me how to rearrange the code properly?
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.
I think we can just delete this go routine.
@@ -299,7 +288,6 @@ func (m *monitor) Start(parentCtx context.Context) { | |||
|
|||
if m.NamespaceInformer != nil { | |||
m.NamespaceInformer.WithContext(m.ctx) | |||
m.NamespaceInformer.WithSyncPeriod(m.informerSyncTime) |
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.
NamespaceInformer is not using factory. Is it OK to delete this setter and use 0 as syncTime in underlying wait.PollImmediateUntil
?
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.
Good question. I used WithSyncPeriod
previously to tune this for tests to reduce the startup time for tests, Since we start this informer only once, tuning the sync period doesn't win us much time and look like a complication without benefits.
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.
It seems we can use DefaultSyncPeriod from factory in namespace_informer, see this commit: 33f3aa9
WDYT?
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.
Not necessarily, but ok. We can do it.
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
781804f
to
ab2f765
Compare
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
Overview
Reuse watch and cache for informers
What this PR does / why we need it
The most resources shell-operator consume to encode and decode watch events.
Special notes for your reviewer
Does this PR introduce a user-facing change?