Skip to content

Commit

Permalink
Adding simple retry for empty value
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 <rook@redhat.com>
  • Loading branch information
Joe Talerico committed Sep 11, 2023
1 parent fef9a09 commit bf42938
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/k8s-netperf/k8s-netperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,13 @@ 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.Info("Rerunning test due to NaN")
r, err := netperf.Run(s.ClientSet, s.RestConfig, nc, Client, serverIP)

Check failure on line 389 in cmd/k8s-netperf/k8s-netperf.go

View workflow job for this annotation

GitHub Actions / build

ineffectual assignment to err (ineffassign)
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 bf42938

Please sign in to comment.