Skip to content

Commit f8ed360

Browse files
committed
Fix: don't try dequeueing a request more than once
1 parent d37d006 commit f8ed360

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

internal/node/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (n *Resources) Init() {
4747
}
4848

4949
func (n *Resources) String() string {
50-
return fmt.Sprintf("[CPUs: %f/%f - Mem: %d(%d warm)/%d]", n.usedCPUs, n.totalCPUs, n.busyPoolUsedMem, n.warmPoolUsedMem, n.totalMemory)
50+
return fmt.Sprintf("[CPUs: %f/%f - Mem: %d(+%d warm)/%d]", n.usedCPUs, n.totalCPUs, n.busyPoolUsedMem, n.warmPoolUsedMem, n.totalMemory)
5151
}
5252

5353
func (n *Resources) FreeMemory() int64 {

internal/node/pool.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,16 @@ func dismissContainer(requiredMemoryMB int64) (bool, error) {
269269
// every container into the funPool has the same memory (same function)
270270
//so it is not important which one you destroy
271271
elem := funPool.idle.Front()
272-
contID := elem.Value.(*container.Container).ID
273272
// container in the same pool need same memory
274-
memory, _ := container.GetMemoryMB(contID)
275-
for ok := true; ok; ok = elem != nil {
276-
containerToDismiss = append(containerToDismiss,
277-
itemToDismiss{contID: contID, pool: funPool, elem: elem, memory: memory})
273+
memory, _ := container.GetMemoryMB(elem.Value.(*container.Container).ID)
274+
275+
for elem != nil {
276+
contID := elem.Value.(*container.Container).ID
277+
containerToDismiss = append(containerToDismiss, itemToDismiss{contID: contID, pool: funPool, elem: elem, memory: memory})
278278
cleanedMB += memory
279279
if cleanedMB >= requiredMemoryMB {
280280
goto cleanup
281281
}
282-
//go on to the next one
283282
elem = elem.Next()
284283
}
285284
}
@@ -317,7 +316,6 @@ func DeleteExpiredContainer() {
317316
if now > warm.ExpirationTime {
318317
temp := elem
319318
elem = elem.Next()
320-
//log.Printf("cleaner: Removing container %s\n", warm.contID)
321319
pool.idle.Remove(temp) // remove the expired element
322320

323321
memory, _ := container.GetMemoryMB(warm.ID)
@@ -326,13 +324,11 @@ func DeleteExpiredContainer() {
326324
if err != nil {
327325
log.Printf("Error while destroying container %s: %s\n", warm.ID, err)
328326
}
329-
// log.Printf("Released resources. Now: %v\n", &LocalResources)
330327
} else {
331328
elem = elem.Next()
332329
}
333330
}
334331
}
335-
336332
}
337333

338334
// ShutdownWarmContainersFor destroys warm containers of a given function

internal/scheduling/policy_default.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ func (p *DefaultLocalPolicy) OnCompletion(_ *function.Function, _ *function.Exec
6060
}, func(e error) {
6161
dropRequest(req)
6262
})
63+
} else {
64+
tryDequeueing = false
6365
}
6466
} else if errors.Is(err, node.OutOfResourcesErr) {
6567
tryDequeueing = false

0 commit comments

Comments
 (0)