mirror of
https://github.com/kubernetes/client-go.git
synced 2026-01-30 05:50:01 +00:00
apimachinery: Use informer.RunWithContext in various components
Kubernetes-commit: 915866f0e414d0afc4f1cc883d86a51a66d74e15
This commit is contained in:
committed by
Kubernetes Publisher
parent
c9ded7e60b
commit
9e310140a3
@@ -25,6 +25,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/informers"
|
||||
"k8s.io/client-go/metadata"
|
||||
@@ -117,8 +118,15 @@ func (f *metadataSharedInformerFactory) ForResource(gvr schema.GroupVersionResou
|
||||
return informer
|
||||
}
|
||||
|
||||
// Start initializes all requested informers.
|
||||
// Start is a legacy wrapper that initializes all requested informers.
|
||||
//
|
||||
//logcheck:context // StartWithContext should be used instead of Start in code which supports contextual logging.
|
||||
func (f *metadataSharedInformerFactory) Start(stopCh <-chan struct{}) {
|
||||
f.StartWithContext(wait.ContextForChannel(stopCh))
|
||||
}
|
||||
|
||||
// StartWithContext initializes all requested informers.
|
||||
func (f *metadataSharedInformerFactory) StartWithContext(ctx context.Context) {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
@@ -135,7 +143,7 @@ func (f *metadataSharedInformerFactory) Start(stopCh <-chan struct{}) {
|
||||
informer := informer.Informer()
|
||||
go func() {
|
||||
defer f.wg.Done()
|
||||
informer.Run(stopCh)
|
||||
informer.RunWithContext(ctx)
|
||||
}()
|
||||
f.startedInformers[informerType] = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user