Skip to content

Commit 4c7e496

Browse files
committed
fix: Add list timeout to prevent one type of resource from causing execution timeout
1 parent 704acaa commit 4c7e496

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
var (
2929
ErrTimedOut = errors.New("execution timed out")
3030

31+
listTimeoutSeconds = int64(30)
3132
executionFailedCounter = 0
3233

3334
debug = os.Getenv("DEBUG") == "true"
@@ -108,9 +109,9 @@ func DoReconcile(dynamicClient dynamic.Interface, resources []*metav1.APIResourc
108109
}
109110
// List all items under the resource
110111
gvr.Resource = apiResource.Name
111-
list, err := dynamicClient.Resource(gvr).List(context.TODO(), metav1.ListOptions{})
112+
list, err := dynamicClient.Resource(gvr).List(context.TODO(), metav1.ListOptions{TimeoutSeconds: &listTimeoutSeconds})
112113
if err != nil {
113-
log.Println(err)
114+
log.Printf("Error checking %s from %s: %s", gvr.Resource, gvr.GroupVersion(), err)
114115
continue
115116
}
116117
if debug {

0 commit comments

Comments
 (0)