fn: reorg agent config (#853)

* fn: reorg agent config

*) Moving constants in agent to agent config, which helps
with testing, tuning.
*) Added max total cpu & memory for testing & clamping max
mem & cpu usage if needed.

* fn: adjust PipeIO time
* fn: for hot, cannot reliably test EndOfLogs in TestRouteRunnerExecution
This commit is contained in:
Tolga Ceylan
2018-03-13 18:38:47 -07:00
committed by GitHub
parent 1988d92c83
commit 74a51f3f88
7 changed files with 105 additions and 68 deletions

View File

@@ -135,7 +135,7 @@ func NewSyncOnly(da DataAccess) Agent {
da: da,
driver: driver,
slotMgr: NewSlotQueueMgr(),
resources: NewResourceTracker(),
resources: NewResourceTracker(cfg),
shutdown: make(chan struct{}),
}
@@ -305,7 +305,7 @@ func (a *agent) hotLauncher(ctx context.Context, call *call) {
// Let use 60 minutes or 2 * IdleTimeout as hot queue idle timeout, pick
// whichever is longer. If in this time, there's no activity, then
// we destroy the hot queue.
timeout := time.Duration(60) * time.Minute
timeout := a.cfg.HotLauncherTimeout
idleTimeout := time.Duration(call.IdleTimeout) * time.Second * 2
if timeout < idleTimeout {
timeout = idleTimeout
@@ -380,7 +380,7 @@ func (a *agent) waitHot(ctx context.Context, call *call) (Slot, error) {
ch := call.slots.startDequeuer(ctx)
// 1) if we can get a slot immediately, grab it.
// 2) if we don't, send a signaller every 200ms until we do.
// 2) if we don't, send a signaller every x msecs until we do.
sleep := 1 * time.Microsecond // pad, so time.After doesn't send immediately
for {
@@ -402,8 +402,8 @@ func (a *agent) waitHot(ctx context.Context, call *call) (Slot, error) {
// ping dequeuer again
}
// set sleep to 200ms after first iteration
sleep = 200 * time.Millisecond
// set sleep to x msecs after first iteration
sleep = a.cfg.HotPoll
// send a notification to launchHot()
select {
case call.slots.signaller <- true:
@@ -631,7 +631,7 @@ func (a *agent) runHot(ctx context.Context, call *call, tok ResourceToken, state
// if freezer is enabled, be consistent with freezer behavior and
// block stdout and stderr between calls.
isBlockIdleIO := MaxDisabledMsecs != a.cfg.FreezeIdleMsecs
isBlockIdleIO := MaxDisabledMsecs != a.cfg.FreezeIdle
container, closer := NewHotContainer(call, isBlockIdleIO)
defer closer()
@@ -708,9 +708,9 @@ func (a *agent) runHotReq(ctx context.Context, call *call, state ContainerState,
var err error
isFrozen := false
freezeTimer := time.NewTimer(a.cfg.FreezeIdleMsecs)
freezeTimer := time.NewTimer(a.cfg.FreezeIdle)
idleTimer := time.NewTimer(time.Duration(call.IdleTimeout) * time.Second)
ejectTicker := time.NewTicker(a.cfg.EjectIdleMsecs)
ejectTicker := time.NewTicker(a.cfg.EjectIdle)
defer freezeTimer.Stop()
defer idleTimer.Stop()
@@ -724,7 +724,7 @@ func (a *agent) runHotReq(ctx context.Context, call *call, state ContainerState,
}()
// if an immediate freeze is requested, freeze first before enqueuing at all.
if a.cfg.FreezeIdleMsecs == time.Duration(0) && !isFrozen {
if a.cfg.FreezeIdle == time.Duration(0) && !isFrozen {
err = cookie.Freeze(ctx)
if err != nil {
return false