Skip to content

Commit 4bd30ed

Browse files
committed
yangerd: containers: widen event debounce to avoid podman contention
1 parent 71d50ea commit 4bd30ed

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/yangerd/internal/containermonitor/containermonitor.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ import (
3131
const (
3232
treeKey = "infix-containers:containers"
3333

34-
// debounceDelay coalesces bursts of events into one re-read.
35-
debounceDelay = 200 * time.Millisecond
34+
// debounceDelay coalesces bursts of events into one re-read. It is
35+
// deliberately generous: container lifecycle events fire while confd
36+
// is still running its own `podman` start/stop/rm operations, so
37+
// re-reading too eagerly makes yangerd's `podman ps/inspect/stats`
38+
// contend with confd for the libpod lock on a CPU-starved guest.
39+
// Waiting for the churn to settle keeps yangerd off confd's back
40+
// during config apply/reset; a couple of seconds of staleness in
41+
// operational data is harmless.
42+
debounceDelay = 2 * time.Second
3643
)
3744

3845
// ContainerMonitor subscribes to container lifecycle events via a

src/yangerd/internal/containermonitor/containermonitor_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ func TestEventTriggersRefresh(t *testing.T) {
6464
// A container "died" event, newline-framed as podman emits it.
6565
go m.readEvents(strings.NewReader(`{"Type":"container","Status":"died","Name":"gone"}` + "\n"))
6666

67-
deadline := time.After(2 * time.Second)
67+
// Must comfortably exceed debounceDelay, or this races the re-read.
68+
deadline := time.After(debounceDelay + 3*time.Second)
6869
for {
6970
if tr.Get(treeKey) == nil && calls > 0 {
7071
break

0 commit comments

Comments
 (0)