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 (
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user