Fix executor not reaps idle function pods for functions with executortype newdeploy (#744)
This commit is contained in:
+19
-5
@@ -23,6 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
"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/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
@@ -85,6 +86,7 @@ func cleanup(client *kubernetes.Clientset, namespace string, instanceId string)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Since different executor type has different idleObjectReaper strategy, move this part to executor type for better code separation.
|
||||||
// idleObjectReaper reaps objects after certain idle time
|
// idleObjectReaper reaps objects after certain idle time
|
||||||
func idleObjectReaper(kubeClient *kubernetes.Clientset,
|
func idleObjectReaper(kubeClient *kubernetes.Clientset,
|
||||||
fissionClient *crd.FissionClient,
|
fissionClient *crd.FissionClient,
|
||||||
@@ -101,8 +103,7 @@ func idleObjectReaper(kubeClient *kubernetes.Clientset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
envList := make(map[types.UID]struct{})
|
envList := make(map[types.UID]struct{})
|
||||||
for i := range envs.Items {
|
for _, env := range envs.Items {
|
||||||
env := envs.Items[i]
|
|
||||||
envList[env.Metadata.UID] = struct{}{}
|
envList[env.Metadata.UID] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,9 +123,23 @@ func idleObjectReaper(kubeClient *kubernetes.Clientset,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn, err := fissionClient.Functions(fsvc.Function.Namespace).Get(fsvc.Function.Name)
|
||||||
|
if err != nil {
|
||||||
// Newdeploy manager handles the function delete event and clean cache/kubeobjs itself,
|
// Newdeploy manager handles the function delete event and clean cache/kubeobjs itself,
|
||||||
// so we ignore the function service cache with newdepoy executor type here.
|
// so we ignore the not found error for functions with newdeploy executor type here.
|
||||||
if fsvc.Executor != fscache.NEWDEPLOY {
|
if errors.IsNotFound(err) && fsvc.Executor == fscache.NEWDEPLOY {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.Printf("Error getting function: %v", fsvc.Function.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore functions of NewDeploy ExecutorType with MinScale > 0
|
||||||
|
if fn.Spec.InvokeStrategy.ExecutionStrategy.MinScale > 0 &&
|
||||||
|
fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fission.ExecutorTypeNewdeploy {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -144,7 +159,6 @@ func idleObjectReaper(kubeClient *kubernetes.Clientset,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func deleteKubeobject(kubeClient *kubernetes.Clientset, kubeobj *apiv1.ObjectReference) {
|
func deleteKubeobject(kubeClient *kubernetes.Clientset, kubeobj *apiv1.ObjectReference) {
|
||||||
switch strings.ToLower(kubeobj.Kind) {
|
switch strings.ToLower(kubeobj.Kind) {
|
||||||
|
|||||||
Reference in New Issue
Block a user