Skip to content

Commit 1db0f55

Browse files
committed
Adding debugging info
1 parent 0175e89 commit 1db0f55

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

internal/container/container.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func GetMemoryMB(id ContainerID) (int64, error) {
133133
}
134134

135135
func Destroy(id ContainerID) error {
136+
log.Printf("Destroying container %s\n", id)
136137
return cf.Destroy(id)
137138
}
138139

internal/node/pool.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package node
33
import (
44
"container/list"
55
"errors"
6+
"fmt"
67
"log"
78
"time"
89

@@ -175,6 +176,8 @@ func HandleCompletion(cont *container.Container, f *function.Function) {
175176
LocalResources.usedCPUs -= f.CPUDemand
176177
LocalResources.busyPoolUsedMem -= f.MemoryMB
177178
LocalResources.warmPoolUsedMem += f.MemoryMB
179+
180+
logPoolStatus()
178181
}
179182
}
180183

@@ -193,6 +196,18 @@ func AcquireResourcesForNewContainer(fun *function.Function, forWarmPool bool) b
193196
if !forWarmPool {
194197
LocalResources.usedCPUs += fun.CPUDemand
195198
}
199+
200+
// Check
201+
if LocalResources.AvailableCPUs() < 0 {
202+
panic("negative CPU availability")
203+
}
204+
if LocalResources.busyPoolUsedMem+LocalResources.warmPoolUsedMem > LocalResources.TotalMemory() {
205+
panic("allocated more memory than available")
206+
}
207+
208+
log.Printf("Acquired resources for %s; now: %v", fun.Name, LocalResources.String())
209+
logPoolStatus()
210+
196211
return true
197212
}
198213

@@ -443,3 +458,11 @@ func PrewarmInstances(f *function.Function, count int64, forcePull bool) (int64,
443458

444459
return spawned, nil
445460
}
461+
func logPoolStatus() {
462+
currPool := make(map[string]string)
463+
for funcName, pool := range LocalResources.containerPools {
464+
currPool[funcName] = fmt.Sprintf("%d(+%d)", pool.idle.Len(), pool.busy.Len())
465+
}
466+
467+
log.Printf("Pool status: %v\n", currPool)
468+
}

0 commit comments

Comments
 (0)