metrics: report: Error more cleanly

Clean up the rest of the report R files to allow them to quit
cleanly when they find an error or missing data, so that the
final PDF report gives meaninful errors such as 'No data found',
rather than cryptic R errors.

Signed-off-by: Graham Whaley <graham.whaley@intel.com>
This commit is contained in:
Graham Whaley
2020-05-13 17:33:35 +01:00
committed by Graham Whaley
parent 058e1753ae
commit 07fd8412da
8 changed files with 1001 additions and 915 deletions
File diff suppressed because it is too large Load Diff
+91 -81
View File
@@ -13,95 +13,105 @@ library(gridExtra) # together.
suppressMessages(suppressWarnings(library(ggpubr))) # for ggtexttable.
suppressMessages(library(jsonlite)) # to load the data.
# A list of all the known results files we might find the information inside.
resultsfiles=c(
"k8s-parallel.json",
"k8s-scaling.json",
"k8s-rapid.json"
)
render_dut_details <- function()
{
# A list of all the known results files we might find the information inside.
resultsfiles=c(
"k8s-parallel.json",
"k8s-scaling.json",
"k8s-rapid.json"
)
data=c()
stats=c()
stats_names=c()
data=c()
stats=c()
stats_names=c()
# For each set of results
for (currentdir in resultdirs) {
count=1
dirstats=c()
for (resultsfile in resultsfiles) {
fname=paste(inputdir, currentdir, resultsfile, sep="/")
if ( !file.exists(fname)) {
#warning(paste("Skipping non-existent file: ", fname))
next
}
# Derive the name from the test result dirname
datasetname=basename(currentdir)
# Import the data
fdata=fromJSON(fname)
if (length(fdata$'kubectl-version') != 0 ) {
# We have kata-runtime data
dirstats=tibble("Client Ver"=as.character(fdata$'kubectl-version'$clientVersion$gitVersion))
dirstats=cbind(dirstats, "Server Ver"=as.character(fdata$'kubectl-version'$serverVersion$gitVersion))
numnodes= nrow(fdata$'kubectl-get-nodes'$items)
dirstats=cbind(dirstats, "No. nodes"=as.character(numnodes))
if (numnodes != 0) {
first_node=fdata$'kubectl-get-nodes'$items[1,]
dirstats=cbind(dirstats, "- Node0 name"=as.character(first_node$metadata$name))
havekata=first_node$metadata$labels$'katacontainers.io/kata-runtime'
if ( is.null(havekata) ) {
dirstats=cbind(dirstats, " Have Kata"=as.character('false'))
} else {
dirstats=cbind(dirstats, " Have Kata"=as.character(havekata))
}
dirstats=cbind(dirstats, " CPUs"=as.character(first_node$status$capacity$cpu))
dirstats=cbind(dirstats, " Memory"=as.character(first_node$status$capacity$memory))
dirstats=cbind(dirstats, " MaxPods"=as.character(first_node$status$capacity$pods))
dirstats=cbind(dirstats, " PodCIDR"=as.character(first_node$spec$podCIDR))
dirstats=cbind(dirstats, " runtime"=as.character(first_node$status$nodeInfo$containerRuntimeVersion))
dirstats=cbind(dirstats, " kernel"=as.character(first_node$status$nodeInfo$kernelVersion))
dirstats=cbind(dirstats, " kubeProxy"=as.character(first_node$status$nodeInfo$kubeProxyVersion))
dirstats=cbind(dirstats, " Kubelet"=as.character(first_node$status$nodeInfo$kubeletVersion))
dirstats=cbind(dirstats, " OS"=as.character(first_node$status$nodeInfo$osImage))
# For each set of results
for (currentdir in resultdirs) {
count=1
dirstats=c()
datasetname=c()
for (resultsfile in resultsfiles) {
fname=paste(inputdir, currentdir, resultsfile, sep="/")
if ( !file.exists(fname)) {
#warning(paste("Skipping non-existent file: ", fname))
next
}
break
# Derive the name from the test result dirname
datasetname=basename(currentdir)
# Import the data
fdata=fromJSON(fname)
if (length(fdata$'kubectl-version') != 0 ) {
# We have kata-runtime data
dirstats=tibble("Client Ver"=as.character(fdata$'kubectl-version'$clientVersion$gitVersion))
dirstats=cbind(dirstats, "Server Ver"=as.character(fdata$'kubectl-version'$serverVersion$gitVersion))
numnodes= nrow(fdata$'kubectl-get-nodes'$items)
dirstats=cbind(dirstats, "No. nodes"=as.character(numnodes))
if (numnodes != 0) {
first_node=fdata$'kubectl-get-nodes'$items[1,]
dirstats=cbind(dirstats, "- Node0 name"=as.character(first_node$metadata$name))
havekata=first_node$metadata$labels$'katacontainers.io/kata-runtime'
if ( is.null(havekata) ) {
dirstats=cbind(dirstats, " Have Kata"=as.character('false'))
} else {
dirstats=cbind(dirstats, " Have Kata"=as.character(havekata))
}
dirstats=cbind(dirstats, " CPUs"=as.character(first_node$status$capacity$cpu))
dirstats=cbind(dirstats, " Memory"=as.character(first_node$status$capacity$memory))
dirstats=cbind(dirstats, " MaxPods"=as.character(first_node$status$capacity$pods))
dirstats=cbind(dirstats, " PodCIDR"=as.character(first_node$spec$podCIDR))
dirstats=cbind(dirstats, " runtime"=as.character(first_node$status$nodeInfo$containerRuntimeVersion))
dirstats=cbind(dirstats, " kernel"=as.character(first_node$status$nodeInfo$kernelVersion))
dirstats=cbind(dirstats, " kubeProxy"=as.character(first_node$status$nodeInfo$kubeProxyVersion))
dirstats=cbind(dirstats, " Kubelet"=as.character(first_node$status$nodeInfo$kubeletVersion))
dirstats=cbind(dirstats, " OS"=as.character(first_node$status$nodeInfo$osImage))
}
break
}
}
if ( length(dirstats) == 0 ) {
cat(paste("No valid data found for directory ", currentdir, "\n\n"))
}
# use plyr rbind.fill so we can combine disparate version info frames
stats=rbind.fill(stats, dirstats)
stats_names=rbind(stats_names, datasetname)
}
if ( length(dirstats) == 0 ) {
warning(paste("No valid data found for directory ", currentdir))
if ( length(stats_names) == 0 ) {
cat("No system details found\n\n")
return()
}
# use plyr rbind.fill so we can combine disparate version info frames
stats=rbind.fill(stats, dirstats)
stats_names=rbind(stats_names, datasetname)
rownames(stats) = stats_names
# Rotate the tibble so we get data dirs as the columns
spun_stats = as_tibble(cbind(What=names(stats), t(stats)))
# Build us a text table of numerical results
# Set up as left hand justify, so the node data indent renders.
tablefontsize=8
tbody.style = tbody_style(hjust=0, x=0.1, size=tablefontsize)
stats_plot = suppressWarnings(ggtexttable(data.frame(spun_stats, check.names=FALSE),
theme=ttheme(base_size=tablefontsize, tbody.style=tbody.style),
rows=NULL
))
# It may seem odd doing a grid of 1x1, but it should ensure we get a uniform format and
# layout to match the other charts and tables in the report.
master_plot = grid.arrange(
stats_plot,
nrow=1,
ncol=1 )
}
rownames(stats) = stats_names
# Rotate the tibble so we get data dirs as the columns
spun_stats = as_tibble(cbind(What=names(stats), t(stats)))
# Build us a text table of numerical results
# Set up as left hand justify, so the node data indent renders.
tablefontsize=8
tbody.style = tbody_style(hjust=0, x=0.1, size=tablefontsize)
stats_plot = suppressWarnings(ggtexttable(data.frame(spun_stats, check.names=FALSE),
theme=ttheme(base_size=tablefontsize, tbody.style=tbody.style),
rows=NULL
))
# It may seem odd doing a grid of 1x1, but it should ensure we get a uniform format and
# layout to match the other charts and tables in the report.
master_plot = grid.arrange(
stats_plot,
nrow=1,
ncol=1 )
render_dut_details()
@@ -0,0 +1,26 @@
library('elasticsearchr')
for_scaling <- query('{
"bool": {
"must": [
{ "match":
{
"test.testname": "k8s scaling"
}
}
]
}
}')
these_fields <- select_fields('{
"includes": [
"date.Date",
"k8s-scaling.BootResults.launch_time.Result",
"k8s-scaling.BootResults.n_pods.Result"
]
}')
sort_by_date <- sort_on('[{"date.Date": {"order": "asc"}}]')
x=elastic("http://192.168.0.111:9200", "logtest") %search% (for_scaling + sort_by_date + these_fields)
@@ -32,7 +32,7 @@ This [test](https://github.com/clearlinux/cloud-native-setup/metrics/scaling/k8s
measures the time taken to launch and delete pods in parallel using a deployment. The times
are how long it takes for the whole deployment operation to complete.
```{r parallel, echo=FALSE, fig.cap="K8S parallel pods"}
```{r parallel, echo=FALSE, fig.cap="K8S parallel pods", results='asis'}
source('parallel.R')
```
@@ -57,7 +57,7 @@ This table describes the test system details, as derived from the information co
in the test results files.
```{r dut, echo=FALSE, fig.cap="System configuration details"}
```{r dut, echo=FALSE, fig.cap="System configuration details", results='asis'}
source('dut-details.R')
```
@@ -67,6 +67,6 @@ source('dut-details.R')
This table describes node details within the Kubernetes cluster that have been used for test.
```{r node, echo=FALSE, fig.cap="Node information within Kubernetes cluster"}
```{r node, echo=FALSE, fig.cap="Node information within Kubernetes cluster", results='asis'}
source('node-info.R')
```
+82 -69
View File
@@ -13,83 +13,96 @@ library(gridExtra) # together.
suppressMessages(suppressWarnings(library(ggpubr))) # for ggtexttable.
suppressMessages(library(jsonlite)) # to load the data.
# A list of all the known results files we might find the information inside.
resultsfiles=c(
"k8s-scaling.json"
)
render_node_info <- function()
{
# A list of all the known results files we might find the information inside.
resultsfiles=c(
"k8s-scaling.json"
)
stats=c()
stats_names=c()
max_char_name_node=18
stats=c()
stats_names=c()
datasetname=c()
complete_data=c()
max_char_name_node=18
# list for each dirstats
dirstats_list=list()
j=1
# list for each dirstats
dirstats_list=list()
j=1
# For each set of results
for (currentdir in resultdirs) {
dirstats=c()
for (resultsfile in resultsfiles) {
fname=paste(inputdir, currentdir, resultsfile, sep="/")
if ( !file.exists(fname)) {
next
}
# Derive the name from the test result dirname
datasetname=basename(currentdir)
# Import the data
fdata=fromJSON(fname)
if (length(fdata$'kubectl-version') != 0 ) {
numnodes= nrow(fdata$'kubectl-get-nodes'$items)
for (i in 1:numnodes) {
node_i=fdata$'kubectl-get-nodes'$items[i,]
node_info=fdata$'socketsPerNode'[i,]
# Substring node name so it fits properly into final table
node_name=node_i$metadata$name
if ( nchar(node_name) >= max_char_name_node) {
dirstats=tibble("Node \nname"=as.character(substring(node_name, 1, max_char_name_node)))
} else {
dirstats=tibble("Node \nname"=as.character(node_name))
}
dirstats=cbind(dirstats, "CPUs"=as.character(node_i$status$capacity$cpu))
dirstats=cbind(dirstats, "Memory"=as.character(node_i$status$capacity$memory))
dirstats=cbind(dirstats, "Max \nPods"=as.character(node_i$status$capacity$pods))
dirstats=cbind(dirstats, "Count \nsockets"=as.character(node_info$num_sockets))
dirstats=cbind(dirstats, "Have \nhypervisor"=as.character(node_info$hypervisor))
dirstats=cbind(dirstats, "kernel"=as.character(node_i$status$nodeInfo$kernelVersion))
dirstats=cbind(dirstats, "OS"=as.character(node_i$status$nodeInfo$osImage))
dirstats=cbind(dirstats, "Test"=as.character(datasetname))
dirstats_list[[j]]=dirstats
j=j+1
# For each set of results
for (currentdir in resultdirs) {
dirstats=c()
for (resultsfile in resultsfiles) {
fname=paste(inputdir, currentdir, resultsfile, sep="/")
if ( !file.exists(fname)) {
next
}
# Derive the name from the test result dirname
datasetname=basename(currentdir)
# Import the data
fdata=fromJSON(fname)
if (length(fdata$'kubectl-version') != 0 ) {
numnodes= nrow(fdata$'kubectl-get-nodes'$items)
for (i in 1:numnodes) {
node_i=fdata$'kubectl-get-nodes'$items[i,]
node_info=fdata$'socketsPerNode'[i,]
# Substring node name so it fits properly into final table
node_name=node_i$metadata$name
if ( nchar(node_name) >= max_char_name_node) {
dirstats=tibble("Node \nname"=as.character(substring(node_name, 1, max_char_name_node)))
} else {
dirstats=tibble("Node \nname"=as.character(node_name))
}
dirstats=cbind(dirstats, "CPUs"=as.character(node_i$status$capacity$cpu))
dirstats=cbind(dirstats, "Memory"=as.character(node_i$status$capacity$memory))
dirstats=cbind(dirstats, "Max \nPods"=as.character(node_i$status$capacity$pods))
dirstats=cbind(dirstats, "Count \nsockets"=as.character(node_info$num_sockets))
dirstats=cbind(dirstats, "Have \nhypervisor"=as.character(node_info$hypervisor))
dirstats=cbind(dirstats, "kernel"=as.character(node_i$status$nodeInfo$kernelVersion))
dirstats=cbind(dirstats, "OS"=as.character(node_i$status$nodeInfo$osImage))
dirstats=cbind(dirstats, "Test"=as.character(datasetname))
dirstats_list[[j]]=dirstats
j=j+1
}
complete_data = do.call(rbind, dirstats_list)
}
complete_data = do.call(rbind, dirstats_list)
}
if ( length(complete_data) == 0 ) {
cat(paste("No valid data found for directory ", currentdir, "\n\n"))
}
# use plyr rbind.fill so we can combine disparate version info frames
stats=rbind.fill(stats, complete_data)
stats_names=rbind(stats_names, datasetname)
}
if ( length(complete_data) == 0 ) {
warning(paste("No valid data found for directory ", currentdir))
if ( length(stats_names) == 0 ) {
cat("No node stats found\n\n");
return()
}
# use plyr rbind.fill so we can combine disparate version info frames
stats=rbind.fill(stats, complete_data)
stats_names=rbind(stats_names, datasetname)
# Build us a text table of numerical results
# Set up as left hand justify, so the node data indent renders.
tablefontsize=8
tbody.style = tbody_style(hjust=0, x=0.1, size=tablefontsize)
stats_plot = suppressWarnings(ggtexttable(data.frame(complete_data, check.names=FALSE),
theme=ttheme(base_size=tablefontsize, tbody.style=tbody.style),
rows=NULL))
# It may seem odd doing a grid of 1x1, but it should ensure we get a uniform format and
# layout to match the other charts and tables in the report.
master_plot = grid.arrange(stats_plot,
nrow=1,
ncol=1 )
}
# Build us a text table of numerical results
# Set up as left hand justify, so the node data indent renders.
tablefontsize=8
tbody.style = tbody_style(hjust=0, x=0.1, size=tablefontsize)
stats_plot = suppressWarnings(ggtexttable(data.frame(complete_data, check.names=FALSE),
theme=ttheme(base_size=tablefontsize, tbody.style=tbody.style),
rows=NULL))
# It may seem odd doing a grid of 1x1, but it should ensure we get a uniform format and
# layout to match the other charts and tables in the report.
master_plot = grid.arrange(stats_plot,
nrow=1,
ncol=1 )
render_node_info()
+106 -96
View File
@@ -13,113 +13,123 @@ suppressMessages(suppressWarnings(library(ggpubr))) # for ggtexttable.
suppressMessages(library(jsonlite)) # to load the data.
suppressMessages(library(scales)) # For de-science notation of axis
testnames=c(
"k8s-parallel*"
)
render_parallel <- function()
{
testnames=c(
"k8s-parallel*"
)
data=c()
stats=c()
rstats=c()
rstats_names=c()
cstats=c()
cstats_names=c()
data=c()
stats=c()
rstats=c()
rstats_names=c()
cstats=c()
cstats_names=c()
skip_points_enable_smooth=0 # Should we draw the points as well as lines on the graphs.
skip_points_enable_smooth=0 # Should we draw the points as well as lines on the graphs.
for (currentdir in resultdirs) {
dirstats=c()
for (testname in testnames) {
matchdir=paste(inputdir, currentdir, sep="")
matchfile=paste(testname, '\\.json', sep="")
files=list.files(matchdir, pattern=matchfile)
if ( length(files) == 0 ) {
#warning(paste("Pattern [", matchdir, "/", matchfile, "] matched nothing"))
}
for (ffound in files) {
fname=paste(inputdir, currentdir, ffound, sep="")
if ( !file.exists(fname)) {
warning(paste("Skipping non-existent file: ", fname))
next
for (currentdir in resultdirs) {
dirstats=c()
for (testname in testnames) {
matchdir=paste(inputdir, currentdir, sep="")
matchfile=paste(testname, '\\.json', sep="")
files=list.files(matchdir, pattern=matchfile)
if ( length(files) == 0 ) {
#warning(paste("Pattern [", matchdir, "/", matchfile, "] matched nothing"))
}
for (ffound in files) {
fname=paste(inputdir, currentdir, ffound, sep="")
if ( !file.exists(fname)) {
warning(paste("Skipping non-existent file: ", fname))
next
}
# Derive the name from the test result dirname
datasetname=basename(currentdir)
# Derive the name from the test result dirname
datasetname=basename(currentdir)
# Import the data
fdata=fromJSON(fname)
# De-nest the test name specific data
shortname=substr(ffound, 1, nchar(ffound)-nchar(".json"))
fdata=fdata[[shortname]]
# Import the data
fdata=fromJSON(fname)
# De-nest the test name specific data
shortname=substr(ffound, 1, nchar(ffound)-nchar(".json"))
fdata=fdata[[shortname]]
testname=datasetname
testname=datasetname
# convert ms to seconds
cdata=data.frame(boot_time=as.numeric(fdata$BootResults$launch_time$Result)/1000)
cdata=cbind(cdata, delete_time=as.numeric(fdata$BootResults$delete_time$Result)/1000)
cdata=cbind(cdata, npod=as.numeric(fdata$BootResults$n_pods$Result))
# convert ms to seconds
cdata=data.frame(boot_time=as.numeric(fdata$BootResults$launch_time$Result)/1000)
cdata=cbind(cdata, delete_time=as.numeric(fdata$BootResults$delete_time$Result)/1000)
cdata=cbind(cdata, npod=as.numeric(fdata$BootResults$n_pods$Result))
# If we have more than 20 items to draw, then do not draw the points on
# the graphs, as they are then too noisy to read.
# But, do draw the smoothed lines to help read the now dense and potentially
# noisy graphs.
if (length(cdata[, "boot_time"]) > 20) {
skip_points_enable_smooth=1
# If we have more than 20 items to draw, then do not draw the points on
# the graphs, as they are then too noisy to read.
# But, do draw the smoothed lines to help read the now dense and potentially
# noisy graphs.
if (length(cdata[, "boot_time"]) > 20) {
skip_points_enable_smooth=1
}
cdata=cbind(cdata, testname=rep(testname, length(cdata[, "boot_time"]) ))
cdata=cbind(cdata, dataset=rep(datasetname, length(cdata[, "boot_time"]) ))
# Store away as a single set
data=rbind(data, cdata)
}
cdata=cbind(cdata, testname=rep(testname, length(cdata[, "boot_time"]) ))
cdata=cbind(cdata, dataset=rep(datasetname, length(cdata[, "boot_time"]) ))
# Store away as a single set
data=rbind(data, cdata)
}
}
# If we found nothing to process, quit early and nicely
if ( length(data) == 0 ) {
cat("No results files found for parallel tests\n\n")
return()
}
# Show how boot time changed
boot_line_plot <- ggplot( data=data, aes(npod, boot_time, colour=testname, group=dataset)) +
geom_line( alpha=0.2) +
xlab("parallel pods") +
ylab("Boot time (s)") +
ggtitle("Deployment boot time (detail)") +
#ylim(0, NA) + # For big machines, better to not 0-index
theme(axis.text.x=element_text(angle=90))
if ( skip_points_enable_smooth == 0 ) {
boot_line_plot = boot_line_plot + geom_point(alpha=0.3)
} else {
boot_line_plot = bool_line_plot + geom_smooth(se=FALSE, method="loess", size=0.3)
}
# And get a zero Y index plot.
boot_line_plot_zero = boot_line_plot + ylim(0, NA) +
ggtitle("Deployment boot time (0 index)")
# Show how boot time changed
delete_line_plot <- ggplot( data=data, aes(npod, delete_time, colour=testname, group=dataset)) +
geom_line(alpha=0.2) +
xlab("parallel pods") +
ylab("Delete time (s)") +
ggtitle("Deployment deletion time (detail)") +
#ylim(0, NA) + # For big machines, better to not 0-index
theme(axis.text.x=element_text(angle=90))
if ( skip_points_enable_smooth == 0 ) {
delete_line_plot = delete_line_plot + geom_point(alpha=0.3)
} else {
delete_line_plot = delete_line_plot + geom_smooth(se=FALSE, method="loess", size=0.3)
}
# And get a 0 indexed Y axis plot
delete_line_plot_zero = delete_line_plot + ylim(0, NA) +
ggtitle("Deployment deletion time (0 index)")
# See https://www.r-bloggers.com/ggplot2-easy-way-to-mix-multiple-graphs-on-the-same-page/ for
# excellent examples
master_plot = grid.arrange(
boot_line_plot_zero,
delete_line_plot_zero,
boot_line_plot,
delete_line_plot,
nrow=2,
ncol=2 )
}
# Show how boot time changed
boot_line_plot <- ggplot( data=data, aes(npod, boot_time, colour=testname, group=dataset)) +
geom_line( alpha=0.2) +
xlab("parallel pods") +
ylab("Boot time (s)") +
ggtitle("Deployment boot time (detail)") +
#ylim(0, NA) + # For big machines, better to not 0-index
theme(axis.text.x=element_text(angle=90))
if ( skip_points_enable_smooth == 0 ) {
boot_line_plot = boot_line_plot + geom_point(alpha=0.3)
} else {
boot_line_plot = bool_line_plot + geom_smooth(se=FALSE, method="loess", size=0.3)
}
# And get a zero Y index plot.
boot_line_plot_zero = boot_line_plot + ylim(0, NA) +
ggtitle("Deployment boot time (0 index)")
# Show how boot time changed
delete_line_plot <- ggplot( data=data, aes(npod, delete_time, colour=testname, group=dataset)) +
geom_line(alpha=0.2) +
xlab("parallel pods") +
ylab("Delete time (s)") +
ggtitle("Deployment deletion time (detail)") +
#ylim(0, NA) + # For big machines, better to not 0-index
theme(axis.text.x=element_text(angle=90))
if ( skip_points_enable_smooth == 0 ) {
delete_line_plot = delete_line_plot + geom_point(alpha=0.3)
} else {
delete_line_plot = delete_line_plot + geom_smooth(se=FALSE, method="loess", size=0.3)
}
# And get a 0 indexed Y axis plot
delete_line_plot_zero = delete_line_plot + ylim(0, NA) +
ggtitle("Deployment deletion time (0 index)")
# See https://www.r-bloggers.com/ggplot2-easy-way-to-mix-multiple-graphs-on-the-same-page/ for
# excellent examples
master_plot = grid.arrange(
boot_line_plot_zero,
delete_line_plot_zero,
boot_line_plot,
delete_line_plot,
nrow=2,
ncol=2 )
render_parallel()
+9
View File
@@ -0,0 +1,9 @@
suppressMessages(library(jsonlite)) # to load the data.
options(digits=22)
x=fromJSON('{"ns": 1567002188374607769}')
print(x)
print(fromJSON('{"ns": 1567002188374607769}'), digits=22)
@@ -205,7 +205,7 @@ render_tidy_scaling <- function()
# Check if we got any stats at all by checking the memstats data. If we found no data,
# abort early and nicely
if ( length(memstats) == 0 ) {
cat("No results files found for scaling tests\n")
cat("No results files found for scaling tests\n\n")
return()
}