Skip to content

Commit

Permalink
Adding simple retry for empty value (#104)
Browse files Browse the repository at this point in the history
We are seeing `NaN` in some CI runs. This is due to no output from
netperf. This change makes a second attempt in the event the parsing
fails to succeed.

Signed-off-by: Joe Talerico <[email protected]>
Co-authored-by: Joe Talerico <[email protected]>
  • Loading branch information
jtaleric and Joe Talerico authored Sep 15, 2023
1 parent f157194 commit a302966
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/k8s-netperf/k8s-netperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,17 @@ func executeWorkload(nc config.Config, s config.PerfScenarios, hostNet bool, ipe
nr, err = netperf.ParseResults(&r)
if err != nil {
log.Error(err)
os.Exit(1)
log.Warn("Rerunning test.")
r, err := netperf.Run(s.ClientSet, s.RestConfig, nc, Client, serverIP)
if err != nil {
log.Error(err)
os.Exit(1)
}
nr, err = netperf.ParseResults(&r)
if err != nil {
log.Error(err)
os.Exit(1)
}
}
}
npr.LossSummary = append(npr.LossSummary, float64(nr.LossPercent))
Expand Down
4 changes: 4 additions & 0 deletions pkg/netperf/netperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"math"
"strconv"
"strings"

Expand Down Expand Up @@ -114,6 +115,9 @@ func ParseResults(stdout *bytes.Buffer) (sample.Sample, error) {
sample.Retransmits, _ = strconv.ParseFloat(strings.Trim(l[1], "\r"), 64)
}
}
if math.IsNaN(sample.Throughput) {
return sample, fmt.Errorf("Throughput value is NaN")
}
sample.LossPercent = 100 - (recv / send * 100)
return sample, nil
}

0 comments on commit a302966

Please sign in to comment.