Issue #2258 Reafctor ready pod conroller to use lister and cache sync checks (#2259)

Reactored ready pod controller code to user lister and cache sync checks,
so that we avoid querying lister if cache is not synced in choodPod function.
Also, as noticied in #2258 we were initializing workqueue in goroutine
which was causing nil pointer reference. We have moved it out of goroutine
and kept specific parts in goroutine.

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2021-11-10 16:00:57 +05:30
committed by GitHub
parent 65e842b1c8
commit 81e247e1e8
3 changed files with 53 additions and 40 deletions
+10
View File
@@ -13,6 +13,16 @@ import (
v1 "github.com/fission/fission/pkg/apis/core/v1"
)
func GetInformerFactoryByReadyPod(client *kubernetes.Clientset, namespace string, labelSelector *metav1.LabelSelector) (k8sInformers.SharedInformerFactory, error) {
informerFactory := k8sInformers.NewSharedInformerFactoryWithOptions(client, 0,
k8sInformers.WithNamespace(namespace),
k8sInformers.WithTweakListOptions(func(options *metav1.ListOptions) {
options.LabelSelector = labels.Set(labelSelector.MatchLabels).AsSelector().String()
options.FieldSelector = "status.phase=Running"
}))
return informerFactory, nil
}
func GetInformerFactoryByExecutor(client *kubernetes.Clientset, executorType v1.ExecutorType, defaultResync time.Duration) (k8sInformers.SharedInformerFactory, error) {
executorLabel, err := labels.NewRequirement(v1.EXECUTOR_TYPE, selection.DoubleEquals, []string{string(executorType)})
if err != nil {