diff --git a/cmd/k8s-netperf/k8s-netperf.go b/cmd/k8s-netperf/k8s-netperf.go index 4e2ec9b6..6e32bcd2 100644 --- a/cmd/k8s-netperf/k8s-netperf.go +++ b/cmd/k8s-netperf/k8s-netperf.go @@ -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)) diff --git a/pkg/netperf/netperf.go b/pkg/netperf/netperf.go index de8e6269..21a1c3e9 100644 --- a/pkg/netperf/netperf.go +++ b/pkg/netperf/netperf.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "math" "strconv" "strings" @@ -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 }