Fix executor failed to clean cache & kubeobjs after function deleted (#534)

This commit is contained in:
Ta-Ching Chen
2018-03-14 02:29:12 +08:00
committed by GitHub
parent 8a0abc59db
commit 048ab6149a
+14 -6
View File
@@ -22,6 +22,7 @@ import (
"strings" "strings"
"time" "time"
"k8s.io/apimachinery/pkg/api/errors"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
@@ -117,18 +118,24 @@ func idleObjectReaper(kubeClient *kubernetes.Clientset,
for _, fsvc := range funcSvcs { for _, fsvc := range funcSvcs {
fn, err := fissionClient.Functions(fsvc.Function.Namespace).Get(fsvc.Function.Name) fn, err := fissionClient.Functions(fsvc.Function.Namespace).Get(fsvc.Function.Name)
if err == nil {
// Ignore functions of NewDeploy ExecutorType with MinScale > 0
if fn.Spec.InvokeStrategy.ExecutionStrategy.MinScale > 0 &&
fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fission.ExecutorTypeNewdeploy {
continue
}
}
if err != nil { // Return errors not equal to "is not found" error
if err != nil && !errors.IsNotFound(err) {
log.Printf("Error getting function: %v", fsvc.Function.Name) log.Printf("Error getting function: %v", fsvc.Function.Name)
continue continue
} }
// Ignore functions of NewDeploy ExecutorType with MinScale > 0 // Newdeploy manager handles the function delete event and clean cache/kubeobjs itself,
if fn.Spec.InvokeStrategy.ExecutionStrategy.MinScale > 0 && fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fission.ExecutorTypeNewdeploy { // so we ignore the function service cache with newdepoy executor type here.
continue if fsvc.Executor != fscache.NEWDEPLOY {
}
deleted, err := fsCache.DeleteOld(fsvc, idlePodReapTime) deleted, err := fsCache.DeleteOld(fsvc, idlePodReapTime)
if err != nil { if err != nil {
log.Printf("Error deleting Kubernetes objects for fsvc '%v': %v", fsvc, err) log.Printf("Error deleting Kubernetes objects for fsvc '%v': %v", fsvc, err)
log.Printf("Object Name| Object Kind | Object Namespace") log.Printf("Object Name| Object Kind | Object Namespace")
@@ -147,6 +154,7 @@ func idleObjectReaper(kubeClient *kubernetes.Clientset,
} }
} }
} }
}
func deleteKubeobject(kubeClient *kubernetes.Clientset, kubeobj *api.ObjectReference) { func deleteKubeobject(kubeClient *kubernetes.Clientset, kubeobj *api.ObjectReference) {
switch strings.ToLower(kubeobj.Kind) { switch strings.ToLower(kubeobj.Kind) {