Skip to content

Commit

Permalink
Fix race condition when a pod is updated when the channel hasn't been…
Browse files Browse the repository at this point in the history
… closed yet

Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Sep 22, 2021
1 parent b9d4032 commit 4dbb869
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/measurements/pod_latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,18 @@ func (p *podLatency) startAndSync() error {

// Stop stops podLatency measurement
func (p *podLatency) stop() (int, error) {
normalizeMetrics()
calcQuantiles()
rc := p.checkThreshold()
defer close(p.stopChannel)
timeoutCh := make(chan struct{})
timeoutTimer := time.AfterFunc(informerTimeout, func() {
close(timeoutCh)
})
defer timeoutTimer.Stop()
if !cache.WaitForCacheSync(timeoutCh, p.informer.HasSynced) {
return rc, fmt.Errorf("Pod-latency: Timed out waiting for caches to sync")
return 0, fmt.Errorf("Pod-latency: Timed out waiting for caches to sync")
}
timeoutTimer.Stop()
close(p.stopChannel)
normalizeMetrics()
calcQuantiles()
rc := p.checkThreshold()
if kubeburnerCfg.WriteToFile {
if err := p.writeToFile(); err != nil {
log.Errorf("Error writing measurement podLatency: %s", err)
Expand Down
2 changes: 2 additions & 0 deletions test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ check_files () {
if [[ ! -f $f ]]; then
log "File ${f} not present"
rc=1
continue
fi
cat $f | jq .
done
}

Expand Down

0 comments on commit 4dbb869

Please sign in to comment.