1
0
mirror of https://github.com/coreos/prometheus-operator.git synced 2026-02-05 06:45:27 +01:00

chore: refactor shared functions in pkg/prometeus

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier
2024-10-23 10:59:20 +02:00
parent 2fc85bb66d
commit 7ac474a3b8
10 changed files with 225 additions and 236 deletions

View File

@@ -66,6 +66,7 @@ func (f *Framework) NewTestCtx(t *testing.T) *TestCtx {
tc.collectAlertmanagers(b, f)
tc.collectPrometheuses(b, f)
tc.collectThanosRulers(b, f)
tc.collectPrometheusAgents(b, f)
tc.collectLogs(b, f)
tc.collectEvents(b, f)
@@ -154,6 +155,21 @@ func (ctx *TestCtx) collectPrometheuses(w io.Writer, f *Framework) {
}
}
func (ctx *TestCtx) collectPrometheusAgents(w io.Writer, f *Framework) {
fmt.Fprintln(w, "=== PrometheusAgents")
for _, ns := range ctx.namespaces {
ps, err := f.MonClientV1alpha1.PrometheusAgents(ns).List(context.Background(), metav1.ListOptions{})
if err != nil {
fmt.Fprintf(w, "%s: failed to get prometheusagents: %v\n", ns, err)
continue
}
for _, p := range ps.Items {
collectConditions(w, fmt.Sprintf("PrometheusAgent=%s/%s", p.Namespace, p.Name), p.Status.Conditions)
}
}
}
func (ctx *TestCtx) collectThanosRulers(w io.Writer, f *Framework) {
fmt.Fprintln(w, "=== ThanosRulers")
for _, ns := range ctx.namespaces {

View File

@@ -71,6 +71,7 @@ func (f *Framework) WritePodLogs(ctx context.Context, w io.Writer, ns, pod strin
fmt.Fprintf(w, "=== Logs (pod=%s/%s container=%s)\n", ns, pod, c)
_, err = w.Write(resp)
fmt.Fprint(w, "\n")
if err != nil {
return fmt.Errorf("failed to write logs: %w", err)
}