From 98830569e8e69b80a4f64b327631007f38716ca6 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Sun, 19 Jan 2025 16:34:44 -0800 Subject: [PATCH] [chore] check for pods len before accessing item 0 --- cmd/gather/cluster/cluster.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/gather/cluster/cluster.go b/cmd/gather/cluster/cluster.go index 3d289fb6ae..2f1e05b1d4 100644 --- a/cmd/gather/cluster/cluster.go +++ b/cmd/gather/cluster/cluster.go @@ -16,6 +16,7 @@ package cluster import ( "context" + "errors" "fmt" "log" "os" @@ -104,6 +105,10 @@ func (c *Cluster) GetOperatorLogs() error { return err } + if len(operatorPods.Items) == 0 { + return errors.New("no operator pods found") + } + pod := operatorPods.Items[0] c.getPodLogs(pod.Name, pod.Namespace, "manager") return nil