Skip to content

Commit

Permalink
Fix concurrent map writes panic
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Oct 4, 2023
1 parent 910eae8 commit 4bf8749
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BIN_NAME = ingress-perf
BIN_PATH = $(BIN_DIR)/$(BIN_NAME)
SOURCES = $(shell find . -type f -name "*.go")
CGO = 0
VEGETA_VERSION := 12.11.1
VEGETA_VERSION := 12.9.0

.PHONY: build lint clean

Expand Down
21 changes: 10 additions & 11 deletions pkg/runner/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,10 @@ func runBenchmark(cfg config.Config, clusterMetadata tools.ClusterMetadata) ([]t
var benchmarkResult []tools.Result
var clientPods []corev1.Pod
var ep string
var tool tools.Tool
r, err := orClientSet.RouteV1().Routes(benchmarkNs).Get(context.TODO(), fmt.Sprintf("%s-%s", serverName, cfg.Termination), metav1.GetOptions{})
if err != nil {
return benchmarkResult, err
}
if cfg.Termination == "http" {
ep = fmt.Sprintf("http://%v%v", r.Spec.Host, cfg.Path)
} else {
ep = fmt.Sprintf("https://%v%v", r.Spec.Host, cfg.Path)
}
tool, err = tools.New(cfg, ep)
if err != nil {
return benchmarkResult, err
}
allClientPods, err := clientSet.CoreV1().Pods(benchmarkNs).List(context.TODO(), metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", clientName),
})
Expand Down Expand Up @@ -85,8 +75,17 @@ func runBenchmark(cfg config.Config, clusterMetadata tools.ClusterMetadata) ([]t
for _, pod := range clientPods {
for i := 0; i < cfg.Procs; i++ {
func(p corev1.Pod) {
log.Debugf("Running %v in client pods", tool.Cmd())
errGroup.Go(func() error {
if cfg.Termination == "http" {
ep = fmt.Sprintf("http://%v%v", r.Spec.Host, cfg.Path)
} else {
ep = fmt.Sprintf("https://%v%v", r.Spec.Host, cfg.Path)
}
tool, err := tools.New(cfg, ep)
log.Debugf("Running %v in client pods", tool.Cmd())
if err != nil {
return err
}
return exec(context.TODO(), tool, p, &result)
})
}(pod)
Expand Down

0 comments on commit 4bf8749

Please sign in to comment.