Skip to content

Commit

Permalink
fix: prevent map concurrent writes panic in the agent (#4019)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathnogueira authored Sep 18, 2024
1 parent 41de914 commit 8e36937
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions agent/runner/runstrategy_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package runner
import (
"context"
"fmt"
"sync"
"time"

"github.com/kubeshop/tracetest/agent/collector"
Expand Down Expand Up @@ -60,6 +61,7 @@ func (s *Runner) disableLogger() func() {
type dashboardObserver struct {
runs map[string]models.TestRun
sensor sensors.Sensor
mutex sync.Mutex
}

func (o *dashboardObserver) EndDataStoreConnection(*proto.DataStoreConnectionTestRequest, error) {
Expand Down Expand Up @@ -130,6 +132,8 @@ func (o *dashboardObserver) getRun(testID string, runID int32) models.TestRun {
}

func (o *dashboardObserver) setRun(model models.TestRun) {
o.mutex.Lock()
defer o.mutex.Unlock()
o.runs[fmt.Sprintf("%s-%s", model.TestID, model.RunID)] = model
}

Expand Down

0 comments on commit 8e36937

Please sign in to comment.