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

fix: many namespace lead to provider stuck #1386

Merged
merged 4 commits into from
Dec 12, 2022

Conversation

shareinto
Copy link
Contributor

Type of change:

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

What this PR does / why we need it:

Resolve: #1378

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@AlinsRan
Copy link
Contributor

This is not correct, because informer is not started, which will not get any objects.

@codecov-commenter
Copy link

Codecov Report

Merging #1386 (d590755) into master (8a17eea) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1386   +/-   ##
=======================================
  Coverage   40.47%   40.47%           
=======================================
  Files          78       78           
  Lines        7076     7076           
=======================================
  Hits         2864     2864           
  Misses       3897     3897           
  Partials      315      315           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@AlinsRan AlinsRan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay.
I thinking using Labels.Nothing() is not correct. This will not get the object.
https://pkg.go.dev/k8s.io/apimachinery/pkg/labels#Nothing

switch p.common.Config.Kubernetes.APIVersion {
case config.ApisixV2beta3:
retRoutes, err := p.common.KubeClient.APISIXClient.ApisixV2beta3().ApisixRoutes(ns).List(ctx, opts)
retRoutes, err := p.apisixSharedInformerFactory.Apisix().V2beta3().ApisixRoutes().Lister().ApisixRoutes(ns).List(labels.Nothing())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
retRoutes, err := p.apisixSharedInformerFactory.Apisix().V2beta3().ApisixRoutes().Lister().ApisixRoutes(ns).List(labels.Nothing())
retRoutes, err := p.apisixSharedInformerFactory.Apisix().V2beta3().ApisixRoutes().Lister().ApisixRoutes(ns).List(labels.Everything())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reminding, I'll fix it as soon as possible

@@ -93,13 +96,13 @@ func (p *apisixProvider) Init(ctx context.Context) error {
}
}
case config.ApisixV2:
retRoutes, err := p.common.KubeClient.APISIXClient.ApisixV2().ApisixRoutes(ns).List(ctx, opts)
retRoutes, err := p.apisixSharedInformerFactory.Apisix().V2().ApisixRoutes().Lister().ApisixRoutes(ns).List(labels.Nothing())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@@ -138,13 +141,13 @@ func (p *apisixProvider) Init(ctx context.Context) error {
switch p.common.Config.Kubernetes.APIVersion {
case config.ApisixV2beta3:
// ApisixConsumer
retConsumer, err := p.common.KubeClient.APISIXClient.ApisixV2beta3().ApisixConsumers(ns).List(ctx, opts)
retConsumer, err := p.apisixSharedInformerFactory.Apisix().V2beta3().ApisixConsumers().Lister().ApisixConsumers(ns).List(labels.Nothing())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@@ -154,13 +157,13 @@ func (p *apisixProvider) Init(ctx context.Context) error {
}
}
// ApisixTls
retSSL, err := p.common.KubeClient.APISIXClient.ApisixV2beta3().ApisixTlses(ns).List(ctx, opts)
retSSL, err := p.apisixSharedInformerFactory.Apisix().V2beta3().ApisixTlses().Lister().ApisixTlses(ns).List(labels.Nothing())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@@ -171,13 +174,13 @@ func (p *apisixProvider) Init(ctx context.Context) error {
}
case config.ApisixV2:
// ApisixConsumer
retConsumer, err := p.common.KubeClient.APISIXClient.ApisixV2().ApisixConsumers(ns).List(ctx, opts)
retConsumer, err := p.apisixSharedInformerFactory.Apisix().V2().ApisixConsumers().Lister().ApisixConsumers(ns).List(labels.Nothing())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@@ -187,13 +190,13 @@ func (p *apisixProvider) Init(ctx context.Context) error {
}
}
// ApisixTls
retSSL, err := p.common.KubeClient.APISIXClient.ApisixV2().ApisixTlses(ns).List(ctx, opts)
retSSL, err := p.apisixSharedInformerFactory.Apisix().V2().ApisixTlses().Lister().ApisixTlses(ns).List(labels.Nothing())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@AlinsRan
Copy link
Contributor

AlinsRan commented Dec 2, 2022

We have a lot of informer.run(), cache.wait() in our code, actually it only needs to call factor.start() and factor.wait() to complete.
There is a conflict between them and they can only be started once. I suggest that the codes of informer.run and cache.wait() should be deleted.

What do you think?

cc @tao12345666333

@@ -48,23 +48,26 @@ func (p *apisixProvider) Init(ctx context.Context) error {
pluginConfigMapA6 = make(map[string]string)
)

p.apisixSharedInformerFactory.Start(ctx.Done())
p.apisixSharedInformerFactory.WaitForCacheSync(ctx.Done())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check its return value, and log it.

	synced := p.apisixSharedInformerFactory.WaitForCacheSync(ctx.Done())

	for v, ok := range synced {
		if !ok {
			// Log it and return
		}
	}

@tao12345666333
Copy link
Member

We have a lot of informer.run(), cache.wait() in our code, actually it only needs to call factor.start() and factor.wait() to complete.

There is a conflict between them and they can only be started once. I suggest that the codes of informer.run and cache.wait() should be deleted.

What do you think?

cc @tao12345666333

Sorry, I forgot to reply you. I think so. Meanwhile, I think it can be done in a follow-up PR

@tao12345666333 tao12345666333 added this to the v1.6.0 milestone Dec 12, 2022
@tao12345666333 tao12345666333 merged commit 7e8f076 into apache:master Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

bug: init stuck cause many namespaces
5 participants