From 0e157be8f873d9ea2522728245ff73af9a083660 Mon Sep 17 00:00:00 2001 From: Daniel Franz Date: Wed, 2 Dec 2026 14:22:03 +0900 Subject: [PATCH] Performance Summary Updates Update the performance summary output at the end of e2e runs by: 1. Add object-controller to the final output 2. Add top-level summary for more readily readable results 3. Cleanup summary generation code and templates for maintainability 4. Split performance alerts into critical and warning categories - the former of which will fail the e2e run (controller panics, etc.) Co-Authored-By: Claude Opus 4.8 Signed-off-by: Daniel Franz --- test/internal/e2e/runner.go | 11 +- test/internal/e2e/summary_test.go | 54 ++- test/internal/summary/summary.go | 377 ++++++++++++------ test/internal/summary/templates/alert.md.tmpl | 16 - .../summary/templates/mermaid_chart.md.tmpl | 17 - .../summary/templates/summary.md.tmpl | 96 ++++- testdata/prometheus/values.yaml | 111 +++++- 7 files changed, 494 insertions(+), 188 deletions(-) delete mode 100644 test/internal/summary/templates/alert.md.tmpl delete mode 100644 test/internal/summary/templates/mermaid_chart.md.tmpl diff --git a/test/internal/e2e/runner.go b/test/internal/e2e/runner.go index 90a6a12863..9b02408e22 100644 --- a/test/internal/e2e/runner.go +++ b/test/internal/e2e/runner.go @@ -56,9 +56,14 @@ func Run(featureDir string, suiteInitializer func(*godog.TestSuiteContext), scen path := os.Getenv("E2E_SUMMARY_OUTPUT") if path == "" { fmt.Println("Note: E2E_SUMMARY_OUTPUT is unset; skipping summary generation") - } else if err := summary.PrintSummary(path); err != nil { - // Alert but do not fail the run if alerts are found. - fmt.Printf("%v", err) + return 0 + } + if err := summary.PrintSummary(path); err != nil { + // Only critical alerts (e.g. reconciler panics) return an error here; + // performance alerts over a threshold are informational and do not fail + // the run. + fmt.Printf("%v\n", err) + return 1 } return 0 } diff --git a/test/internal/e2e/summary_test.go b/test/internal/e2e/summary_test.go index fb13abb2d6..b2f04f3bbd 100644 --- a/test/internal/e2e/summary_test.go +++ b/test/internal/e2e/summary_test.go @@ -33,8 +33,60 @@ func TestSummaryOutsideSuiteDirectory(t *testing.T) { require.NoError(t, summary.PrintSummary(path)) content, err := os.ReadFile(path) require.NoError(t, err) - require.Contains(t, string(content), "# E2E Summary") + require.Contains(t, string(content), "# ๐Ÿงช E2E Test Summary") require.Contains(t, string(content), "operator-controller") require.Contains(t, string(content), "catalogd") + require.Contains(t, string(content), "object-controller") require.Contains(t, string(content), "xychart-beta") } + +// summaryServer serves a Prometheus-compatible response with the given alerts +// JSON (the contents of data.alerts) and a single-sample matrix for any query. +func summaryServer(t *testing.T, alertsJSON string) *httptest.Server { + t.Helper() + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + switch r.URL.Path { + case "/api/v1/alerts": + fmt.Fprintf(w, `{"status":"success","data":{"alerts":[%s]}}`, alertsJSON) + case "/api/v1/query": + fmt.Fprint(w, `{"status":"success","data":{"resultType":"matrix","result":[{"metric":{},"values":[[1,"1"]]}]}}`) + default: + http.NotFound(w, r) + } + })) + t.Cleanup(server.Close) + return server +} + +func TestSummaryCriticalAlertFailsRun(t *testing.T) { + alertsJSON := `{"labels":{"alertname":"reconciler-panic","severity":"critical"},` + + `"annotations":{"description":"pod panicked"},"state":"firing","activeAt":"2026-12-02T10:30:00Z"}` + server := summaryServer(t, alertsJSON) + t.Setenv("PROMETHEUS_URL", server.URL) + + path := filepath.Join(t.TempDir(), "summary.md") + err := summary.PrintSummary(path) + require.Error(t, err) + require.Contains(t, err.Error(), "reconciler-panic") + + content, err := os.ReadFile(path) + require.NoError(t, err) + require.Contains(t, string(content), "critical alert(s) firing") + require.Contains(t, string(content), "reconciler-panic") +} + +func TestSummaryWarningAlertDoesNotFailRun(t *testing.T) { + alertsJSON := `{"labels":{"alertname":"catalogd-cpu-usage","severity":"warning"},` + + `"annotations":{"description":"high cpu"},"state":"firing","activeAt":"2026-12-02T10:30:00Z"}` + server := summaryServer(t, alertsJSON) + t.Setenv("PROMETHEUS_URL", server.URL) + + path := filepath.Join(t.TempDir(), "summary.md") + require.NoError(t, summary.PrintSummary(path)) + + content, err := os.ReadFile(path) + require.NoError(t, err) + require.Contains(t, string(content), "performance alert(s) over threshold") + require.Contains(t, string(content), "catalogd-cpu-usage") +} diff --git a/test/internal/summary/summary.go b/test/internal/summary/summary.go index a764be4ee6..9ef8f1e936 100644 --- a/test/internal/summary/summary.go +++ b/test/internal/summary/summary.go @@ -15,164 +15,253 @@ import ( "github.com/prometheus/common/model" ) -var ( - summaryTemplate = "summary.md.tmpl" - alertsTemplate = "alert.md.tmpl" - chartTemplate = "mermaid_chart.md.tmpl" -) - //go:embed templates/*.tmpl var templates embed.FS -type summaryAlerts struct { - FiringAlerts []summaryAlert - PendingAlerts []summaryAlert +// queryTimeout bounds every individual Prometheus query. +const queryTimeout = 10 * time.Second + +// severityCritical is the value of an alert's "severity" label that marks it as +// a hard failure (e.g. a reconciler panic). Critical firing alerts fail the e2e +// run; all other firing alerts are informational and only shown in the summary. +const severityCritical = "critical" + +// components are the controllers charted in the summary, in display order. +// A component with no metrics in Prometheus (e.g. object-controller in a +// standard install) is omitted from the output rather than failing the run. +var components = []string{"operator-controller", "catalogd", "object-controller"} + +// metric describes a single time series to chart for every component. +// Query must contain exactly one %s verb, which is replaced with the +// component name to build the pod/job matcher. +type metric struct { + Title string + Query string + YLabel string + // Scaler converts raw samples into the human-readable unit named by + // YLabel (e.g. bytes -> MB uses 1e-6). + Scaler float64 +} + +// metrics are the per-component charts, in display order. +var metrics = []metric{ + { + Title: "Memory Usage", + Query: `container_memory_working_set_bytes{pod=~"%s.*",container="manager"}[5m]`, + YLabel: "MB", + Scaler: 1e-6, + }, + { + Title: "Memory Growth Rate", + Query: `deriv(sum(container_memory_working_set_bytes{pod=~"%s.*",container="manager"})[5m:])[5m:]`, + YLabel: "KB/s", + Scaler: 1e-3, + }, + { + Title: "CPU Usage", + Query: `rate(container_cpu_usage_seconds_total{pod=~"%s.*",container="manager"}[5m])[5m:]`, + YLabel: "mCPU", + Scaler: 1000, + }, + { + Title: "API Queries Total", + Query: `sum(rest_client_requests_total{job=~"%s.*"})[5m:]`, + YLabel: "# queries", + Scaler: 1, + }, + { + Title: "API Query Rate", + Query: `sum(rate(rest_client_requests_total{job=~"%s.*"}[5m]))[5m:]`, + YLabel: "per sec", + Scaler: 1, + }, } -type summaryAlert struct { - v1.Alert +// report is the fully-resolved data model handed to the summary template. +// All Prometheus querying happens before rendering, so the template is pure +// presentation with no method calls that can fail mid-render. +type report struct { + // CriticalAlerts are firing alerts labelled severity=critical. These fail + // the run. + CriticalAlerts []alert + // WarningAlerts are firing alerts that are not critical (e.g. performance + // thresholds). These are informational only. + WarningAlerts []alert + PendingAlerts []alert + Components []componentReport +} + +// CriticalAlertsFiring reports whether any critical alert is firing. +func (r report) CriticalAlertsFiring() bool { return len(r.CriticalAlerts) > 0 } + +// NoAlerts reports whether there are no firing alerts of any severity. +func (r report) NoAlerts() bool { return len(r.CriticalAlerts) == 0 && len(r.WarningAlerts) == 0 } + +// alert is a single Prometheus alert flattened for display. +type alert struct { Name string Description string + Severity string + State v1.AlertState + ActiveAt time.Time } -type xychart struct { +// critical reports whether the alert is labelled severity=critical. +func (a alert) critical() bool { return a.Severity == severityCritical } + +// componentReport holds every chart rendered for a single component. +type componentReport struct { + Name string + Charts []chart +} + +// chart is a single resolved xychart plus the summary statistics shown in the +// at-a-glance table. +type chart struct { Title string - YMax float64 - YMin float64 YLabel string - Data string + YMin float64 + YMax float64 + Peak float64 + Latest float64 + // Data is the mermaid line-series literal, e.g. "[1,2,3]". + Data string } -type githubSummary struct { - client api.Client - Pods []string - alertsFiring bool +// collector queries a Prometheus instance to build a report. +type collector struct { + api v1.API } -func NewSummary(c api.Client, pods ...string) githubSummary { - return githubSummary{ - client: c, - Pods: pods, - alertsFiring: false, - } +func newCollector(c api.Client) *collector { + return &collector{api: v1.NewAPI(c)} } -// PerformanceQuery queries the prometheus server and generates a mermaid xychart with the data. -// title - Display name of the xychart -// pod - Pod name with which to filter results from prometheus -// query - Prometheus query -// yLabel - Label of the Y axis i.e. "KB/s", "MB", etc. -// scaler - Constant by which to scale the results. For instance, cpu usage is more human-readable -// as "mCPU" vs "CPU", so we scale the results by a factor of 1,000. -func (s *githubSummary) PerformanceQuery(title, pod, query, yLabel string, scaler float64) (string, error) { - v1api := v1.NewAPI(s.client) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - - fullQuery := fmt.Sprintf(query, pod) - result, warnings, _, err := v1api.Query(ctx, fullQuery, time.Now()) +// collect builds the full report, querying alerts and every component chart. +// Missing component metrics are skipped; query failures are logged and the +// affected chart is omitted so a single bad query never blanks the summary. +func (c *collector) collect() (report, error) { + alerts, err := c.alerts() if err != nil { - return "", err - } else if len(warnings) > 0 { - fmt.Printf("warnings returned from performance query; query=%s, warnings=%v", fullQuery, warnings) - } else if result.Type() != model.ValMatrix { - return "", fmt.Errorf("incompatible result type; need: %s, got: %s", model.ValMatrix, result.Type().String()) + return report{}, fmt.Errorf("querying alerts: %w", err) } - matrix, ok := result.(model.Matrix) - if !ok { - return "", fmt.Errorf("typecast for metrics samples failed; aborting") - } else if len(matrix) == 0 { - return "", fmt.Errorf("expected 1 or more sets of results; got 0") - } - chart := xychart{ - Title: title, - YLabel: yLabel, - YMax: math.SmallestNonzeroFloat64, - YMin: math.MaxFloat64, - } - formattedData := make([]string, 0) - // matrix does not allow [] access, so we just do one iteration for the single result - for _, metric := range matrix { - for _, sample := range metric.Values { - floatSample := float64(sample.Value) * scaler - formattedData = append(formattedData, fmt.Sprintf("%f", floatSample)) - if floatSample > chart.YMax { - chart.YMax = floatSample - } - if floatSample < chart.YMin { - chart.YMin = floatSample + r := report{} + for _, a := range alerts { + switch a.State { + case v1.AlertStateFiring: + if a.critical() { + r.CriticalAlerts = append(r.CriticalAlerts, a) + } else { + r.WarningAlerts = append(r.WarningAlerts, a) } + case v1.AlertStatePending: + r.PendingAlerts = append(r.PendingAlerts, a) + // Inactive alerts are not returned by the alerts endpoint. } } - // Add some padding - chart.YMax = (chart.YMax + (math.Abs(chart.YMax) * 0.05)) - chart.YMin = (chart.YMin - (math.Abs(chart.YMin) * 0.05)) - // Pretty print the values, ex: [1,2,3,4] - chart.Data = strings.ReplaceAll(fmt.Sprintf("%v", formattedData), " ", ",") - return executeTemplate(chartTemplate, chart) + for _, name := range components { + cr := componentReport{Name: name} + for _, m := range metrics { + ch, found, err := c.chart(name, m) + switch { + case err != nil: + fmt.Printf("warning: %s %q query failed: %v\n", name, m.Title, err) + case found: + cr.Charts = append(cr.Charts, ch) + } + } + if len(cr.Charts) > 0 { + r.Components = append(r.Components, cr) + } + } + return r, nil } -// Alerts queries the prometheus server for alerts and generates markdown output for anything found. -// If no alerts are found, the alerts section will contain only "None." in the final output. -func (s *githubSummary) Alerts() (string, error) { - v1api := v1.NewAPI(s.client) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) +// chart runs a single metric query for a component. The returned bool is false +// (with a nil error) when the component reports no samples, which is the normal +// case for a component that is not deployed. +func (c *collector) chart(component string, m metric) (chart, bool, error) { + ctx, cancel := context.WithTimeout(context.Background(), queryTimeout) defer cancel() - result, err := v1api.Alerts(ctx) + + query := fmt.Sprintf(m.Query, component) + result, warnings, _, err := c.api.Query(ctx, query, time.Now()) if err != nil { - return "", err + return chart{}, false, err + } + if len(warnings) > 0 { + fmt.Printf("warnings from query %q: %v\n", query, warnings) + } + if result.Type() != model.ValMatrix { + return chart{}, false, fmt.Errorf("unexpected result type: want %s, got %s", model.ValMatrix, result.Type()) + } + matrix, ok := result.(model.Matrix) + if !ok { + return chart{}, false, fmt.Errorf("could not cast result to matrix") + } + if len(matrix) == 0 { + // No data for this component; treat as absent rather than an error. + return chart{}, false, nil } - firingAlerts := make([]summaryAlert, 0) - pendingAlerts := make([]summaryAlert, 0) - if len(result.Alerts) > 0 { - for _, a := range result.Alerts { - aConv := summaryAlert{ - Alert: a, - Name: string(a.Labels["alertname"]), - Description: string(a.Annotations["description"]), - } - switch a.State { - case v1.AlertStateFiring: - firingAlerts = append(firingAlerts, aConv) - s.alertsFiring = true - case v1.AlertStatePending: - pendingAlerts = append(pendingAlerts, aConv) - // Ignore AlertStateInactive; the alerts endpoint doesn't return them - } + ch := chart{ + Title: m.Title, + YLabel: m.YLabel, + YMax: math.SmallestNonzeroFloat64, + YMin: math.MaxFloat64, + } + values := make([]string, 0) + // A matrix is not indexable; iterate the single expected series. + for _, series := range matrix { + for _, sample := range series.Values { + v := float64(sample.Value) * m.Scaler + values = append(values, fmt.Sprintf("%f", v)) + ch.YMax = math.Max(ch.YMax, v) + ch.YMin = math.Min(ch.YMin, v) + ch.Latest = v } - } else { - return "None.", nil } + ch.Peak = ch.YMax + // Pad the axis so peaks and troughs are not flush against the frame. + ch.YMax += math.Abs(ch.YMax) * 0.05 + ch.YMin -= math.Abs(ch.YMin) * 0.05 + // Render the mermaid literal, e.g. [1,2,3]. + ch.Data = strings.ReplaceAll(fmt.Sprintf("%v", values), " ", ",") - return executeTemplate(alertsTemplate, summaryAlerts{ - FiringAlerts: firingAlerts, - PendingAlerts: pendingAlerts, - }) + return ch, true, nil } -func executeTemplate(templateFile string, obj any) (string, error) { - tmpl, err := template.New(templateFile).ParseFS(templates, "templates/"+templateFile) +// alerts fetches and flattens the current Prometheus alerts. +func (c *collector) alerts() ([]alert, error) { + ctx, cancel := context.WithTimeout(context.Background(), queryTimeout) + defer cancel() + + result, err := c.api.Alerts(ctx) if err != nil { - return "", err + return nil, err } - buffer := new(strings.Builder) - err = tmpl.Execute(buffer, obj) - if err != nil { - return "", err + alerts := make([]alert, 0, len(result.Alerts)) + for _, a := range result.Alerts { + alerts = append(alerts, alert{ + Name: string(a.Labels["alertname"]), + Description: string(a.Annotations["description"]), + Severity: string(a.Labels["severity"]), + State: a.State, + ActiveAt: a.ActiveAt, + }) } - return buffer.String(), nil + return alerts, nil } -// PrintSummary executes the main summary template, generating the full test report. -// The markdown is template-driven; the summary methods are called from within the -// template. This allows us to add or change queries (hopefully) without needing to -// touch code. The summary will be output to a file supplied by the env target. +// PrintSummary queries Prometheus and writes the rendered markdown summary to +// path. It never fails the test run for rendering or query problems (those are +// logged); it returns a non-nil error only when alerts are firing, so callers +// can surface that condition. func PrintSummary(path string) error { if path == "" { - fmt.Printf("No summary output path specified; skipping") + fmt.Println("No summary output path specified; skipping") return nil } promURL := os.Getenv("PROMETHEUS_URL") @@ -181,28 +270,60 @@ func PrintSummary(path string) error { return nil } - client, err := api.NewClient(api.Config{ - Address: promURL, - }) + client, err := api.NewClient(api.Config{Address: promURL}) if err != nil { - fmt.Printf("warning: failed to initialize promQL client: %v", err) + fmt.Printf("warning: failed to initialize promQL client: %v\n", err) return nil } - summary := NewSummary(client, "operator-controller", "catalogd") - summaryMarkdown, err := executeTemplate(summaryTemplate, &summary) + r, err := newCollector(client).collect() if err != nil { - fmt.Printf("warning: failed to generate e2e test summary: %v", err) + fmt.Printf("warning: failed to collect e2e summary data: %v\n", err) return nil } - err = os.WriteFile(path, []byte(summaryMarkdown), 0o600) + + markdown, err := render(r) if err != nil { - fmt.Printf("warning: failed to write e2e test summary output to %s: %v", path, err) + fmt.Printf("warning: failed to render e2e test summary: %v\n", err) return nil } - fmt.Printf("Test summary output to %s successful\n", path) - if summary.alertsFiring { - return fmt.Errorf("performance alerts encountered during test run; please check e2e test summary for details") + if err := os.WriteFile(path, []byte(markdown), 0o600); err != nil { + fmt.Printf("warning: failed to write e2e test summary to %s: %v\n", path, err) + return nil + } + fmt.Printf("Test summary written to %s\n", path) + + if r.CriticalAlertsFiring() { + names := make([]string, 0, len(r.CriticalAlerts)) + for _, a := range r.CriticalAlerts { + names = append(names, a.Name) + } + return fmt.Errorf("critical alerts firing during test run: %s; see the e2e test summary for details", strings.Join(names, ", ")) } return nil } + +// render executes the summary template against the resolved report. +func render(r report) (string, error) { + tmpl, err := template.New("summary.md.tmpl").Funcs(template.FuncMap{ + "num": formatNumber, + }).ParseFS(templates, "templates/*.tmpl") + if err != nil { + return "", err + } + var buf strings.Builder + if err := tmpl.ExecuteTemplate(&buf, "summary.md.tmpl", r); err != nil { + return "", err + } + return buf.String(), nil +} + +// formatNumber renders a float for the stats table: trimmed to two decimals, +// without a trailing ".00" for whole numbers. +func formatNumber(f float64) string { + s := strings.TrimRight(strings.TrimRight(fmt.Sprintf("%.2f", f), "0"), ".") + if s == "" || s == "-0" { + return "0" + } + return s +} diff --git a/test/internal/summary/templates/alert.md.tmpl b/test/internal/summary/templates/alert.md.tmpl deleted file mode 100644 index 39f3e42879..0000000000 --- a/test/internal/summary/templates/alert.md.tmpl +++ /dev/null @@ -1,16 +0,0 @@ -{{- /* -------------------- Alert Template --------------------- */ -}} -{{define "alert"}} -| {{ .Name }} | {{ .Description }} | -| -------- | ------- | -| ActiveAt | {{ .ActiveAt }} | -| State | {{ .State }} | -{{- end}} - -### Firing Alerts -{{ range .FiringAlerts }} -{{ template "alert" .}} -{{ end }} -### Pending Alerts -{{ range .PendingAlerts }} -{{ template "alert" .}} -{{ end }} diff --git a/test/internal/summary/templates/mermaid_chart.md.tmpl b/test/internal/summary/templates/mermaid_chart.md.tmpl deleted file mode 100644 index 0a8ed1135b..0000000000 --- a/test/internal/summary/templates/mermaid_chart.md.tmpl +++ /dev/null @@ -1,17 +0,0 @@ -
- -```mermaid ---- -config: - xyChart: - showDataLabel: true - xAxis: - showLabel: false ---- -xychart-beta -title "{{ .Title }}" -y-axis "{{ .YLabel }}" {{printf "%f" .YMin}} --> {{printf "%f" .YMax}} -x-axis "time (start of test to end)" -line {{.Data}} -``` -
diff --git a/test/internal/summary/templates/summary.md.tmpl b/test/internal/summary/templates/summary.md.tmpl index b1372b8740..433b8ccf96 100644 --- a/test/internal/summary/templates/summary.md.tmpl +++ b/test/internal/summary/templates/summary.md.tmpl @@ -1,29 +1,81 @@ +{{- /* + E2E test summary rendered to the GitHub step summary. -{{- /* ------------ Performance Statistics Template ------------ */ -}} -{{define "performanceStatistics" -}} -{{ range $index, $pod := .Pods }} -### {{$pod}} -#### Memory Usage -{{$.PerformanceQuery "Memory Usage" $pod `container_memory_working_set_bytes{pod=~"%s.*",container="manager"}[5m]` "MB" .000001}} + The template is pure presentation: every value below is pre-resolved by the + collector in summary.go. Sub-templates are defined inline to keep the whole + report in one file. +*/ -}} +{{- define "alertsTable" -}} +| Alert | Active At | Description | +| --- | --- | --- | +{{ range . -}} +| `{{ .Name }}` | {{ .ActiveAt.Format "2006-01-02 15:04:05 MST" }} | {{ .Description }} | +{{ end -}} +{{- end -}} -#### Memory Growth Rate -{{$.PerformanceQuery "Memory Growth Rate" $pod `deriv(sum(container_memory_working_set_bytes{pod=~"%s.*",container="manager"})[5m:])[5m:]` "KB/s" .001}} +{{- define "chart" -}} +#### {{ .Title }} -#### CPU Usage -{{$.PerformanceQuery "CPU Usage" $pod `rate(container_cpu_usage_seconds_total{pod=~"%s.*",container="manager"}[5m])[5m:]` "mCPU" 1000}} +```mermaid +--- +config: + xyChart: + showDataLabel: true + xAxis: + showLabel: false +--- +xychart-beta +title "{{ .Title }} ({{ .YLabel }})" +y-axis "{{ .YLabel }}" {{ printf "%f" .YMin }} --> {{ printf "%f" .YMax }} +x-axis "time (start of test to end)" +line {{ .Data }} +``` +{{ end -}} -#### API Queries Total -{{$.PerformanceQuery "API Queries Total" $pod `sum(rest_client_requests_total{job=~"%s.*"})[5m:]` "# queries" 1}} +{{- define "component" -}} +### {{ .Name }} -#### API Query Rate -{{$.PerformanceQuery "API Queries/sec" $pod `sum(rate(rest_client_requests_total{job=~"%s.*"}[5m]))[5m:]` "per sec" 1}} +| Metric | Peak | Latest | +| --- | ---: | ---: | +{{ range .Charts -}} +| {{ .Title }} | {{ num .Peak }} {{ .YLabel }} | {{ num .Latest }} {{ .YLabel }} | +{{ end }} +
+๐Ÿ“ˆ Charts -{{end}} -{{- end}} +{{ range .Charts }}{{ template "chart" . }}{{ end -}} +
+{{ end -}} -{{- /* ----------------- E2E Summary Markdown ------------------ */ -}} -# E2E Summary -## Alerts -{{.Alerts}} -## Performance -{{ template "performanceStatistics" . -}} +{{- /* ---------------------------- Report --------------------------------- */ -}} +# ๐Ÿงช E2E Test Summary + +## ๐Ÿšจ Alerts + +{{ if .CriticalAlerts -}} +โ›” **{{ len .CriticalAlerts }} critical alert(s) firing โ€” this fails the run.** + +{{ template "alertsTable" .CriticalAlerts }} +{{ end -}} +{{- if .WarningAlerts }} +โš ๏ธ **{{ len .WarningAlerts }} performance alert(s) over threshold** (informational). + +{{ template "alertsTable" .WarningAlerts }} +{{ end -}} +{{- if .NoAlerts }} +โœ… No alerts firing. +{{ end }} +{{- if .PendingAlerts }} +
+โš ๏ธ {{ len .PendingAlerts }} alert(s) pending + +{{ template "alertsTable" .PendingAlerts }} +
+{{ end }} +## ๐Ÿ“Š Performance +{{ if .Components }} +{{ range .Components }}{{ template "component" . }} +{{ end -}} +{{ else }} +_No performance metrics were collected._ +{{ end -}} diff --git a/testdata/prometheus/values.yaml b/testdata/prometheus/values.yaml index 7c2cce1245..d33a05609c 100644 --- a/testdata/prometheus/values.yaml +++ b/testdata/prometheus/values.yaml @@ -103,6 +103,33 @@ prometheus: key: tls.key name: CATALOGD_CERT_PLACEHOLDER serverName: catalogd-service.olmv1-system.svc + # object-controller only exists in experimental installs; this monitor + # selects nothing in a standard install, and the e2e summary omits any + # component with no scraped metrics. + - name: object-controller-controller-manager-metrics-monitor + selector: + matchLabels: + app.kubernetes.io/name: object-controller + endpoints: + - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token + interval: 10s + path: /metrics + port: metrics + scheme: https + tlsConfig: + ca: + secret: + key: ca.crt + name: object-controller-cert + cert: + secret: + key: tls.crt + name: object-controller-cert + insecureSkipVerify: false + keySecret: + key: tls.key + name: object-controller-cert + serverName: object-controller-service.olmv1-system.svc kubelet: enabled: true namespace: kube-system @@ -118,7 +145,7 @@ kubelet: cAdvisorRelabelings: [] cAdvisorMetricRelabelings: - sourceLabels: [pod, container] - regex: "(operator-controller|catalogd).*;manager" + regex: "(operator-controller|catalogd|object-controller).*;manager" action: keep additionalPrometheusRulesMap: controller-panic-alerts: @@ -128,10 +155,15 @@ additionalPrometheusRulesMap: - alert: reconciler-panic annotations: description: "controller of pod {{ $labels.pod }} experienced panic(s); count={{ $value }}" + labels: + # critical alerts fail the e2e run (see test/internal/summary). + severity: critical expr: controller_runtime_reconcile_panics_total{} > 0 - alert: webhook-panic annotations: description: "controller webhook of pod {{ $labels.pod }} experienced panic(s); count={{ $value }}" + labels: + severity: critical expr: controller_runtime_webhook_panics_total{} > 0 controller-resource-alerts: groups: @@ -140,52 +172,129 @@ additionalPrometheusRulesMap: - alert: oom-events annotations: description: "container {{ $labels.container }} of pod {{ $labels.pod }} experienced OOM event(s); count={{ $value }}" + labels: + # an OOM kill is a real failure, not just a stat over a threshold. + severity: critical expr: container_oom_events_total > 0 - alert: operator-controller-memory-growth annotations: description: 'operator-controller pod memory usage growing at a high rate for 5 minutes: {{ $value | humanize }}B/sec' expr: deriv(sum(container_memory_working_set_bytes{pod=~"operator-controller.*",container="manager"})[5m:]) > 100000 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning for: 5m keep_firing_for: 1d - alert: catalogd-memory-growth annotations: description: 'catalogd pod memory usage growing at a high rate for 5 minutes: {{ $value | humanize }}B/sec' expr: deriv(sum(container_memory_working_set_bytes{pod=~"catalogd.*",container="manager"})[5m:]) > 100000 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning for: 5m keep_firing_for: 1d - alert: operator-controller-memory-usage annotations: description: 'operator-controller pod using high memory resources for the last 5 minutes: {{ $value | humanize }}B' expr: sum(container_memory_working_set_bytes{pod=~"operator-controller.*",container="manager"}) > 100000000 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning for: 5m keep_firing_for: 1d - alert: catalogd-memory-usage annotations: description: 'catalogd pod using high memory resources for the last 5 minutes: {{ $value | humanize }}B' expr: sum(container_memory_working_set_bytes{pod=~"catalogd.*",container="manager"}) > 75000000 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning for: 5m keep_firing_for: 1d - alert: operator-controller-cpu-usage annotations: description: 'operator-controller using high cpu resource for 5 minutes: {{ $value | printf "%.2f" }}%' expr: rate(container_cpu_usage_seconds_total{pod=~"operator-controller.*",container="manager"}[5m]) * 100 > 20 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning for: 5m keep_firing_for: 1d - alert: catalogd-cpu-usage annotations: description: 'catalogd using high cpu resources for 5 minutes: {{ $value | printf "%.2f" }}%' expr: rate(container_cpu_usage_seconds_total{pod=~"catalogd.*",container="manager"}[5m]) * 100 > 20 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning for: 5m keep_firing_for: 1d - alert: operator-controller-api-call-rate annotations: description: 'operator-controller making excessive API calls for 5 minutes: {{ $value | printf "%.2f" }}/sec' expr: sum(rate(rest_client_requests_total{job=~"operator-controller-service"}[5m])) > 10 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning for: 5m keep_firing_for: 1d - alert: catalogd-api-call-rate annotations: description: 'catalogd making excessive API calls for 5 minutes: {{ $value | printf "%.2f" }}/sec' expr: sum(rate(rest_client_requests_total{job=~"catalogd-service"}[5m])) > 5 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning + for: 5m + keep_firing_for: 1d + # object-controller only runs in experimental installs; these rules + # never fire in a standard install because the series are absent. + - alert: object-controller-memory-growth + annotations: + description: 'object-controller pod memory usage growing at a high rate for 5 minutes: {{ $value | humanize }}B/sec' + expr: deriv(sum(container_memory_working_set_bytes{pod=~"object-controller.*",container="manager"})[5m:]) > 100000 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning + for: 5m + keep_firing_for: 1d + - alert: object-controller-memory-usage + annotations: + description: 'object-controller pod using high memory resources for the last 5 minutes: {{ $value | humanize }}B' + expr: sum(container_memory_working_set_bytes{pod=~"object-controller.*",container="manager"}) > 100000000 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning + for: 5m + keep_firing_for: 1d + - alert: object-controller-cpu-usage + annotations: + description: 'object-controller using high cpu resource for 5 minutes: {{ $value | printf "%.2f" }}%' + expr: rate(container_cpu_usage_seconds_total{pod=~"object-controller.*",container="manager"}[5m]) * 100 > 20 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning + for: 5m + keep_firing_for: 1d + - alert: object-controller-api-call-rate + annotations: + description: 'object-controller making excessive API calls for 5 minutes: {{ $value | printf "%.2f" }}/sec' + expr: sum(rate(rest_client_requests_total{job=~"object-controller-service"}[5m])) > 10 + labels: + # performance threshold alerts are informational; they appear in + # the e2e summary but do not fail the run. + severity: warning for: 5m keep_firing_for: 1d