logger webhook failure can overrun the queue_size (#14556)

PR introduced in #13819 was incorrect and was not
handling the situation where a buffer is full can
cause incessant amount of logs that would keep the
logger webhook overrun by the requests.

To avoid this only log failures to console logger
instead of all targets as it can cause self reference,
leading to an infinite loop.
This commit is contained in:
Harshavardhana
2022-03-15 17:45:51 -07:00
committed by GitHub
parent 77b15e7194
commit ae3b369fe1
2 changed files with 14 additions and 2 deletions

View File

@@ -46,7 +46,11 @@ var (
// Must be immutable at all times.
// Can be swapped to another while holding swapMu
systemTargets = []Target{}
nTargets int32 // atomic count of len(targets)
// This is always set represent /dev/console target
consoleTgt Target
nTargets int32 // atomic count of len(targets)
)
// SystemTargets returns active targets.
@@ -90,6 +94,11 @@ func AddSystemTarget(t Target) error {
return err
}
swapMu.Lock()
if consoleTgt == nil {
if t.Type() == types.TargetConsole {
consoleTgt = t
}
}
updated := append(make([]Target, 0, len(systemTargets)+1), systemTargets...)
updated = append(updated, t)
systemTargets = updated