Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 07fd841

Browse files
Graham Whaleygrahamwhaley
authored andcommitted
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>
1 parent 058e175 commit 07fd841

8 files changed

Lines changed: 991 additions & 905 deletions

File tree

metrics/report/report_dockerfile/collectd_scaling.R

Lines changed: 668 additions & 650 deletions
Large diffs are not rendered by default.

metrics/report/report_dockerfile/dut-details.R

Lines changed: 90 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -13,95 +13,105 @@ library(gridExtra) # together.
1313
suppressMessages(suppressWarnings(library(ggpubr))) # for ggtexttable.
1414
suppressMessages(library(jsonlite)) # to load the data.
1515

16-
# A list of all the known results files we might find the information inside.
17-
resultsfiles=c(
18-
"k8s-parallel.json",
19-
"k8s-scaling.json",
20-
"k8s-rapid.json"
21-
)
22-
23-
data=c()
24-
stats=c()
25-
stats_names=c()
26-
27-
# For each set of results
28-
for (currentdir in resultdirs) {
29-
count=1
30-
dirstats=c()
31-
for (resultsfile in resultsfiles) {
32-
fname=paste(inputdir, currentdir, resultsfile, sep="/")
33-
if ( !file.exists(fname)) {
34-
#warning(paste("Skipping non-existent file: ", fname))
35-
next
36-
}
37-
38-
# Derive the name from the test result dirname
39-
datasetname=basename(currentdir)
40-
41-
# Import the data
42-
fdata=fromJSON(fname)
43-
44-
if (length(fdata$'kubectl-version') != 0 ) {
45-
# We have kata-runtime data
46-
dirstats=tibble("Client Ver"=as.character(fdata$'kubectl-version'$clientVersion$gitVersion))
47-
dirstats=cbind(dirstats, "Server Ver"=as.character(fdata$'kubectl-version'$serverVersion$gitVersion))
48-
numnodes= nrow(fdata$'kubectl-get-nodes'$items)
49-
dirstats=cbind(dirstats, "No. nodes"=as.character(numnodes))
50-
51-
if (numnodes != 0) {
52-
first_node=fdata$'kubectl-get-nodes'$items[1,]
53-
dirstats=cbind(dirstats, "- Node0 name"=as.character(first_node$metadata$name))
16+
render_dut_details <- function()
17+
{
18+
# A list of all the known results files we might find the information inside.
19+
resultsfiles=c(
20+
"k8s-parallel.json",
21+
"k8s-scaling.json",
22+
"k8s-rapid.json"
23+
)
24+
25+
data=c()
26+
stats=c()
27+
stats_names=c()
28+
29+
# For each set of results
30+
for (currentdir in resultdirs) {
31+
count=1
32+
dirstats=c()
33+
datasetname=c()
34+
for (resultsfile in resultsfiles) {
35+
fname=paste(inputdir, currentdir, resultsfile, sep="/")
36+
if ( !file.exists(fname)) {
37+
#warning(paste("Skipping non-existent file: ", fname))
38+
next
39+
}
5440

55-
havekata=first_node$metadata$labels$'katacontainers.io/kata-runtime'
56-
if ( is.null(havekata) ) {
57-
dirstats=cbind(dirstats, " Have Kata"=as.character('false'))
58-
} else {
59-
dirstats=cbind(dirstats, " Have Kata"=as.character(havekata))
41+
# Derive the name from the test result dirname
42+
datasetname=basename(currentdir)
43+
44+
# Import the data
45+
fdata=fromJSON(fname)
46+
47+
if (length(fdata$'kubectl-version') != 0 ) {
48+
# We have kata-runtime data
49+
dirstats=tibble("Client Ver"=as.character(fdata$'kubectl-version'$clientVersion$gitVersion))
50+
dirstats=cbind(dirstats, "Server Ver"=as.character(fdata$'kubectl-version'$serverVersion$gitVersion))
51+
numnodes= nrow(fdata$'kubectl-get-nodes'$items)
52+
dirstats=cbind(dirstats, "No. nodes"=as.character(numnodes))
53+
54+
if (numnodes != 0) {
55+
first_node=fdata$'kubectl-get-nodes'$items[1,]
56+
dirstats=cbind(dirstats, "- Node0 name"=as.character(first_node$metadata$name))
57+
58+
havekata=first_node$metadata$labels$'katacontainers.io/kata-runtime'
59+
if ( is.null(havekata) ) {
60+
dirstats=cbind(dirstats, " Have Kata"=as.character('false'))
61+
} else {
62+
dirstats=cbind(dirstats, " Have Kata"=as.character(havekata))
63+
}
64+
65+
dirstats=cbind(dirstats, " CPUs"=as.character(first_node$status$capacity$cpu))
66+
dirstats=cbind(dirstats, " Memory"=as.character(first_node$status$capacity$memory))
67+
dirstats=cbind(dirstats, " MaxPods"=as.character(first_node$status$capacity$pods))
68+
dirstats=cbind(dirstats, " PodCIDR"=as.character(first_node$spec$podCIDR))
69+
70+
dirstats=cbind(dirstats, " runtime"=as.character(first_node$status$nodeInfo$containerRuntimeVersion))
71+
dirstats=cbind(dirstats, " kernel"=as.character(first_node$status$nodeInfo$kernelVersion))
72+
dirstats=cbind(dirstats, " kubeProxy"=as.character(first_node$status$nodeInfo$kubeProxyVersion))
73+
dirstats=cbind(dirstats, " Kubelet"=as.character(first_node$status$nodeInfo$kubeletVersion))
74+
dirstats=cbind(dirstats, " OS"=as.character(first_node$status$nodeInfo$osImage))
6075
}
6176

62-
dirstats=cbind(dirstats, " CPUs"=as.character(first_node$status$capacity$cpu))
63-
dirstats=cbind(dirstats, " Memory"=as.character(first_node$status$capacity$memory))
64-
dirstats=cbind(dirstats, " MaxPods"=as.character(first_node$status$capacity$pods))
65-
dirstats=cbind(dirstats, " PodCIDR"=as.character(first_node$spec$podCIDR))
66-
67-
dirstats=cbind(dirstats, " runtime"=as.character(first_node$status$nodeInfo$containerRuntimeVersion))
68-
dirstats=cbind(dirstats, " kernel"=as.character(first_node$status$nodeInfo$kernelVersion))
69-
dirstats=cbind(dirstats, " kubeProxy"=as.character(first_node$status$nodeInfo$kubeProxyVersion))
70-
dirstats=cbind(dirstats, " Kubelet"=as.character(first_node$status$nodeInfo$kubeletVersion))
71-
dirstats=cbind(dirstats, " OS"=as.character(first_node$status$nodeInfo$osImage))
77+
break
7278
}
79+
}
7380

74-
break
81+
if ( length(dirstats) == 0 ) {
82+
cat(paste("No valid data found for directory ", currentdir, "\n\n"))
7583
}
84+
85+
# use plyr rbind.fill so we can combine disparate version info frames
86+
stats=rbind.fill(stats, dirstats)
87+
stats_names=rbind(stats_names, datasetname)
7688
}
7789

78-
if ( length(dirstats) == 0 ) {
79-
warning(paste("No valid data found for directory ", currentdir))
90+
if ( length(stats_names) == 0 ) {
91+
cat("No system details found\n\n")
92+
return()
8093
}
8194

82-
# use plyr rbind.fill so we can combine disparate version info frames
83-
stats=rbind.fill(stats, dirstats)
84-
stats_names=rbind(stats_names, datasetname)
95+
rownames(stats) = stats_names
96+
97+
# Rotate the tibble so we get data dirs as the columns
98+
spun_stats = as_tibble(cbind(What=names(stats), t(stats)))
99+
100+
# Build us a text table of numerical results
101+
# Set up as left hand justify, so the node data indent renders.
102+
tablefontsize=8
103+
tbody.style = tbody_style(hjust=0, x=0.1, size=tablefontsize)
104+
stats_plot = suppressWarnings(ggtexttable(data.frame(spun_stats, check.names=FALSE),
105+
theme=ttheme(base_size=tablefontsize, tbody.style=tbody.style),
106+
rows=NULL
107+
))
108+
109+
# It may seem odd doing a grid of 1x1, but it should ensure we get a uniform format and
110+
# layout to match the other charts and tables in the report.
111+
master_plot = grid.arrange(
112+
stats_plot,
113+
nrow=1,
114+
ncol=1 )
85115
}
86116

87-
rownames(stats) = stats_names
88-
89-
# Rotate the tibble so we get data dirs as the columns
90-
spun_stats = as_tibble(cbind(What=names(stats), t(stats)))
91-
92-
# Build us a text table of numerical results
93-
# Set up as left hand justify, so the node data indent renders.
94-
tablefontsize=8
95-
tbody.style = tbody_style(hjust=0, x=0.1, size=tablefontsize)
96-
stats_plot = suppressWarnings(ggtexttable(data.frame(spun_stats, check.names=FALSE),
97-
theme=ttheme(base_size=tablefontsize, tbody.style=tbody.style),
98-
rows=NULL
99-
))
100-
101-
# It may seem odd doing a grid of 1x1, but it should ensure we get a uniform format and
102-
# layout to match the other charts and tables in the report.
103-
master_plot = grid.arrange(
104-
stats_plot,
105-
nrow=1,
106-
ncol=1 )
107-
117+
render_dut_details()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
library('elasticsearchr')
3+
4+
for_scaling <- query('{
5+
"bool": {
6+
"must": [
7+
{ "match":
8+
{
9+
"test.testname": "k8s scaling"
10+
}
11+
}
12+
]
13+
}
14+
}')
15+
16+
these_fields <- select_fields('{
17+
"includes": [
18+
"date.Date",
19+
"k8s-scaling.BootResults.launch_time.Result",
20+
"k8s-scaling.BootResults.n_pods.Result"
21+
]
22+
}')
23+
24+
sort_by_date <- sort_on('[{"date.Date": {"order": "asc"}}]')
25+
26+
x=elastic("http://192.168.0.111:9200", "logtest") %search% (for_scaling + sort_by_date + these_fields)

metrics/report/report_dockerfile/metrics_report.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This [test](https://github.com/clearlinux/cloud-native-setup/metrics/scaling/k8s
3232
measures the time taken to launch and delete pods in parallel using a deployment. The times
3333
are how long it takes for the whole deployment operation to complete.
3434

35-
```{r parallel, echo=FALSE, fig.cap="K8S parallel pods"}
35+
```{r parallel, echo=FALSE, fig.cap="K8S parallel pods", results='asis'}
3636
source('parallel.R')
3737
```
3838

@@ -57,7 +57,7 @@ This table describes the test system details, as derived from the information co
5757
in the test results files.
5858

5959

60-
```{r dut, echo=FALSE, fig.cap="System configuration details"}
60+
```{r dut, echo=FALSE, fig.cap="System configuration details", results='asis'}
6161
source('dut-details.R')
6262
```
6363

@@ -67,6 +67,6 @@ source('dut-details.R')
6767

6868
This table describes node details within the Kubernetes cluster that have been used for test.
6969

70-
```{r node, echo=FALSE, fig.cap="Node information within Kubernetes cluster"}
70+
```{r node, echo=FALSE, fig.cap="Node information within Kubernetes cluster", results='asis'}
7171
source('node-info.R')
7272
```

0 commit comments

Comments
 (0)