From 4c7e4963a091ede110fb3b03b9166c0d6f184cfb Mon Sep 17 00:00:00 2001 From: TwiN Date: Thu, 4 Aug 2022 20:51:52 -0400 Subject: [PATCH] fix: Add list timeout to prevent one type of resource from causing execution timeout --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4a737d2..efd895f 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,7 @@ const ( var ( ErrTimedOut = errors.New("execution timed out") + listTimeoutSeconds = int64(30) executionFailedCounter = 0 debug = os.Getenv("DEBUG") == "true" @@ -108,9 +109,9 @@ func DoReconcile(dynamicClient dynamic.Interface, resources []*metav1.APIResourc } // List all items under the resource gvr.Resource = apiResource.Name - list, err := dynamicClient.Resource(gvr).List(context.TODO(), metav1.ListOptions{}) + list, err := dynamicClient.Resource(gvr).List(context.TODO(), metav1.ListOptions{TimeoutSeconds: &listTimeoutSeconds}) if err != nil { - log.Println(err) + log.Printf("Error checking %s from %s: %s", gvr.Resource, gvr.GroupVersion(), err) continue } if debug {