mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
yangerd: containers: widen event debounce to avoid podman contention
This commit is contained in:
@@ -31,8 +31,15 @@ import (
|
||||
const (
|
||||
treeKey = "infix-containers:containers"
|
||||
|
||||
// debounceDelay coalesces bursts of events into one re-read.
|
||||
debounceDelay = 200 * time.Millisecond
|
||||
// debounceDelay coalesces bursts of events into one re-read. It is
|
||||
// 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
|
||||
|
||||
@@ -64,7 +64,8 @@ func TestEventTriggersRefresh(t *testing.T) {
|
||||
// A container "died" event, newline-framed as podman emits it.
|
||||
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 {
|
||||
if tr.Get(treeKey) == nil && calls > 0 {
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user