yangerd: containers: widen event debounce to avoid podman contention

This commit is contained in:
Mattias Walström
2026-06-27 08:41:22 +02:00
parent 62b890f7b6
commit e32b72d1ee
2 changed files with 11 additions and 3 deletions
@@ -31,8 +31,15 @@ import (
const ( const (
treeKey = "infix-containers:containers" treeKey = "infix-containers:containers"
// debounceDelay coalesces bursts of events into one re-read. // debounceDelay coalesces bursts of events into one re-read. It is
debounceDelay = 200 * time.Millisecond // deliberately generous: container lifecycle events fire while confd
// is still running its own `podman` start/stop/rm operations, so
// re-reading too eagerly makes yangerd's `podman ps/inspect/stats`
// contend with confd for the libpod lock on a CPU-starved guest.
// Waiting for the churn to settle keeps yangerd off confd's back
// during config apply/reset; a couple of seconds of staleness in
// operational data is harmless.
debounceDelay = 2 * time.Second
) )
// ContainerMonitor subscribes to container lifecycle events via a // ContainerMonitor subscribes to container lifecycle events via a
@@ -64,7 +64,8 @@ func TestEventTriggersRefresh(t *testing.T) {
// A container "died" event, newline-framed as podman emits it. // A container "died" event, newline-framed as podman emits it.
go m.readEvents(strings.NewReader(`{"Type":"container","Status":"died","Name":"gone"}` + "\n")) go m.readEvents(strings.NewReader(`{"Type":"container","Status":"died","Name":"gone"}` + "\n"))
deadline := time.After(2 * time.Second) // Must comfortably exceed debounceDelay, or this races the re-read.
deadline := time.After(debounceDelay + 3*time.Second)
for { for {
if tr.Get(treeKey) == nil && calls > 0 { if tr.Get(treeKey) == nil && calls > 0 {
break break