Skip to content
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

Merged
merged 4 commits into from
Aug 31, 2022
Merged

Use Factory for informers #412

merged 4 commits into from
Aug 31, 2022

Conversation

nabokihms
Copy link
Contributor

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?


@nabokihms nabokihms requested a review from diafour July 14, 2022 06:58
@nabokihms nabokihms changed the title Factory test Use Factory for informers Jul 14, 2022
Comment on lines 465 to 470
go func() {
<-ei.ctx.Done()
ei.stopped = true
close(stopCh)
DefaultFactoryStore.Stop(ei.FactoryIndex)
}()

Copy link
Contributor

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().

Copy link
Contributor Author

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?

Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@diafour diafour added this to the 1.1.0 milestone Aug 23, 2022
@diafour diafour linked an issue Aug 23, 2022 that may be closed by this pull request
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
@diafour diafour merged commit c110d1a into main Aug 31, 2022
@diafour diafour modified the milestones: 1.1.0, 1.0.12 Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deduplicate informers for bindings
2 participants