Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more error checking #113

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions cmd/k8s-netperf/k8s-netperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

const namespace = "netperf"
const index = "k8s-netperf"
const retry = 3

var (
cfgfile string
Expand Down Expand Up @@ -389,15 +390,27 @@ func executeWorkload(nc config.Config, s config.PerfScenarios, hostNet bool, ipe
nr, err = netperf.ParseResults(&r)
if err != nil {
log.Error(err)
log.Warn("Rerunning test.")
r, err := netperf.Run(s.ClientSet, s.RestConfig, nc, Client, serverIP)
if err != nil {
log.Error(err)
os.Exit(1)
try := 0
success := false
// Retry the current test.
for try < retry {
log.Warn("Rerunning test.")
r, err := netperf.Run(s.ClientSet, s.RestConfig, nc, Client, serverIP)
if err != nil {
log.Error(err)
continue
}
nr, err = netperf.ParseResults(&r)
if err != nil {
log.Error(err)
try++
} else {
success = true
break
}
}
nr, err = netperf.ParseResults(&r)
if err != nil {
log.Error(err)
if !success {
log.Error("test was unsuccessful after retry.")
os.Exit(1)
}
}
Expand Down
32 changes: 28 additions & 4 deletions pkg/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,34 @@ func BuildDocs(sr result.ScenarioResults, uuid string) ([]interface{}, error) {
ClientNodeLabels: r.ClientNodeLabels,
AcrossAZ: r.AcrossAZ,
}
d.UDPLossPercent, _ = result.Average(r.LossSummary)
d.TCPRetransmit, _ = result.Average(r.RetransmitSummary)
d.Throughput, _ = result.Average(r.ThroughputSummary)
d.Latency, _ = result.Average(r.LatencySummary)
UDPLossPercent, e := result.Average(r.LossSummary)
if e != nil {
logging.Warn("Unable to process udp loss, setting value to zero")
d.UDPLossPercent = 0
} else {
d.UDPLossPercent = UDPLossPercent
}
TCPRetransmit, e := result.Average(r.RetransmitSummary)
if e != nil {
logging.Warn("Unable to process tcp retransmits, setting value to zero")
d.TCPRetransmit = 0
} else {
d.TCPRetransmit = TCPRetransmit
}
Throughput, e := result.Average(r.ThroughputSummary)
if e != nil {
logging.Warn("Unable to process throughput, setting value to zero")
d.Throughput = 0
} else {
d.Throughput = Throughput
}
Latency, e := result.Average(r.LatencySummary)
if e != nil {
logging.Warn("Unable to process latency, setting value to zero")
d.Latency = 0
} else {
d.Latency = Latency
}
docs = append(docs, d)
}
return docs, nil
Expand Down
9 changes: 9 additions & 0 deletions pkg/netperf/netperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ func ParseResults(stdout *bytes.Buffer) (sample.Sample, error) {
if strings.Contains(l[0], "THROUGHPUT_UNITS") {
sample.Metric = l[1]
} else if strings.Contains(l[0], "THROUGHPUT") {
if len(strings.TrimSpace(l[1])) < 1 {
return sample, fmt.Errorf("Throughput was empty.")
}
sample.Throughput, _ = strconv.ParseFloat(strings.Trim(l[1], "\r"), 64)
} else if strings.Contains(l[0], "P99_LATENCY") {
if len(strings.TrimSpace(l[1])) < 1 {
return sample, fmt.Errorf("P99_Latency was empty.")
}
sample.Latency99ptile, _ = strconv.ParseFloat(strings.Trim(l[1], "\r"), 64)
} else if strings.Contains(l[0], "RT_LATENCY") {
sample.Latency, _ = strconv.ParseFloat(strings.Trim(l[1], "\r"), 64)
Expand All @@ -121,6 +127,9 @@ func ParseResults(stdout *bytes.Buffer) (sample.Sample, error) {
if math.IsNaN(sample.Throughput) {
return sample, fmt.Errorf("Throughput value is NaN")
}
if math.IsNaN(sample.Latency99ptile) {
return sample, fmt.Errorf("Latency value is NaN")
}
sample.LossPercent = 100 - (recv / send * 100)
return sample, nil
}
Loading