Differentiate by environment in fscache eviction (#361)

This commit is contained in:
Soam Vasani
2017-09-28 10:00:23 -07:00
committed by GitHub
parent 557c2ee6fc
commit 6734bfbf7b
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -59,6 +59,7 @@ type (
address string
podName string
age time.Duration
env *api.ObjectMeta // used for ListOld
responseChannel chan *fscResponse
}
fscResponse struct {
@@ -98,7 +99,9 @@ func (fsc *functionServiceCache) service() {
resp.error = err
} else {
fsvc := fsvcI.(*funcSvc)
if time.Now().Sub(fsvc.atime) > req.age {
if fsvc.environment.Metadata.UID == req.env.UID &&
time.Now().Sub(fsvc.atime) > req.age {
podName := podNameI.(string)
pods = append(pods, podName)
}
@@ -241,11 +244,12 @@ func (fsc *functionServiceCache) _deleteByPod(podName string, minAge time.Durati
return true, nil
}
func (fsc *functionServiceCache) ListOld(age time.Duration) ([]string, error) {
func (fsc *functionServiceCache) ListOld(env *api.ObjectMeta, age time.Duration) ([]string, error) {
responseChannel := make(chan *fscResponse)
fsc.requestChannel <- &fscRequest{
requestType: LISTOLD,
age: age,
env: env,
responseChannel: responseChannel,
}
resp := <-responseChannel
+1 -1
View File
@@ -620,7 +620,7 @@ func (gp *GenericPool) CleanupFunctionService(podName string) error {
func (gp *GenericPool) idlePodReaper() {
for {
time.Sleep(time.Minute)
podNames, err := gp.fsCache.ListOld(gp.idlePodReapTime)
podNames, err := gp.fsCache.ListOld(&gp.env.Metadata, gp.idlePodReapTime)
if err != nil {
log.Printf("Error reaping idle pods: %v", err)
continue