Lock before iterating map so that code does not panic on concurrent write (#3280)

Signed-off-by: Sascha Schwarze <schwarzs@de.ibm.com>
Co-authored-by: Sascha Schwarze <schwarzs@de.ibm.com>
Co-authored-by: Norman Boewing <boewing@de.ibm.com>
This commit is contained in:
Knative Prow Robot 2025-10-22 16:22:46 +01:00 committed by GitHub
parent 487f9df8d3
commit 7bf6febca0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -121,6 +121,10 @@ func (m *queueMetrics) updateUnfinishedWork() {
// doesn't seem to have non-hacky ways to reset the summary metrics.
var total float64
var oldest float64
m.mu.Lock()
defer m.mu.Unlock()
for _, t := range m.processingStartTimes {
age := m.sinceInSeconds(t)
total += age