Use pool pod controller with env informer (#2161)
Signed-off-by: Sanket Sudake sanketsudake@gmail.com - Use informers and listers in executors - Passing context properly in pool manager executor - Environment updates in the pool manager would not cause updates in the deployment - Environment update minimizing downtime - Use replicaset controller and environment delete triggers to cleanup specialized pods
This commit is contained in:
+3
-16
@@ -1,28 +1,26 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/selection"
|
||||
k8sInformers "k8s.io/client-go/informers"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
metricsapi "k8s.io/metrics/pkg/apis/metrics"
|
||||
|
||||
v1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
)
|
||||
|
||||
func GetInformerFactoryByExecutor(client *kubernetes.Clientset, executorType v1.ExecutorType) (k8sInformers.SharedInformerFactory, error) {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
labelSelector := labels.NewSelector()
|
||||
labelSelector.Add(*executorLabel)
|
||||
informerFactory := k8sInformers.NewSharedInformerFactoryWithOptions(client, 0,
|
||||
informerFactory := k8sInformers.NewSharedInformerFactoryWithOptions(client, defaultResync,
|
||||
k8sInformers.WithTweakListOptions(func(options *metav1.ListOptions) {
|
||||
options.LabelSelector = labelSelector.String()
|
||||
}))
|
||||
@@ -47,14 +45,3 @@ func SupportedMetricsAPIVersionAvailable(discoveredAPIGroups *metav1.APIGroupLis
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func GetCachedItem(obj apiv1.ObjectReference, informer k8sCache.SharedIndexInformer) (item interface{}, exists bool, err error) {
|
||||
store := informer.GetStore()
|
||||
|
||||
item, exists, err = store.Get(obj)
|
||||
if err != nil || !exists {
|
||||
item, exists, err = store.GetByKey(fmt.Sprintf("%s/%s", obj.Namespace, obj.Name))
|
||||
}
|
||||
|
||||
return item, exists, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user