mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: remove eviction timer to simplify eviction logic (#1223)
We tie container pausing with evictions, where if a container is paused, then it is also eligible for eviction.
This commit is contained in:
@@ -1058,11 +1058,9 @@ func (a *agent) runHotReq(ctx context.Context, call *call, state ContainerState,
|
||||
|
||||
freezeTimer := time.NewTimer(a.cfg.FreezeIdle)
|
||||
idleTimer := time.NewTimer(time.Duration(call.IdleTimeout) * time.Second)
|
||||
ejectTimer := time.NewTimer(a.cfg.EjectIdle)
|
||||
|
||||
defer freezeTimer.Stop()
|
||||
defer idleTimer.Stop()
|
||||
defer ejectTimer.Stop()
|
||||
|
||||
// log if any error is encountered
|
||||
defer func() {
|
||||
@@ -1071,6 +1069,8 @@ func (a *agent) runHotReq(ctx context.Context, call *call, state ContainerState,
|
||||
}
|
||||
}()
|
||||
|
||||
evictor := a.evictor.GetEvictor(call.ID, call.slotHashId, call.Memory+uint64(call.TmpFsSize), uint64(call.CPUs))
|
||||
|
||||
// if an immediate freeze is requested, freeze first before enqueuing at all.
|
||||
if a.cfg.FreezeIdle == time.Duration(0) && !isFrozen {
|
||||
err = cookie.Freeze(ctx)
|
||||
@@ -1079,10 +1079,12 @@ func (a *agent) runHotReq(ctx context.Context, call *call, state ContainerState,
|
||||
}
|
||||
isFrozen = true
|
||||
state.UpdateState(ctx, ContainerStatePaused, call.slots)
|
||||
if !isEvictable {
|
||||
isEvictable = true
|
||||
a.evictor.RegisterEvictor(evictor)
|
||||
}
|
||||
}
|
||||
|
||||
evictor := a.evictor.GetEvictor(call.ID, call.slotHashId, call.Memory+uint64(call.TmpFsSize), uint64(call.CPUs))
|
||||
|
||||
if !isFrozen {
|
||||
state.UpdateState(ctx, ContainerStateIdle, call.slots)
|
||||
}
|
||||
@@ -1104,16 +1106,15 @@ func (a *agent) runHotReq(ctx context.Context, call *call, state ContainerState,
|
||||
}
|
||||
isFrozen = true
|
||||
state.UpdateState(ctx, ContainerStatePaused, call.slots)
|
||||
if !isEvictable {
|
||||
isEvictable = true
|
||||
a.evictor.RegisterEvictor(evictor)
|
||||
}
|
||||
}
|
||||
continue
|
||||
case <-evictor.C:
|
||||
logger.Debug("attempting hot function eject")
|
||||
logger.Debug("attempting hot function eviction")
|
||||
isEvictEvent = true
|
||||
case <-ejectTimer.C:
|
||||
// we've been idle too long, now we are ejectable
|
||||
a.evictor.RegisterEvictor(evictor)
|
||||
isEvictable = true
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user