Skip to content

Commit

Permalink
fix: Add list timeout to prevent one type of resource from causing ex…
Browse files Browse the repository at this point in the history
…ecution timeout
  • Loading branch information
TwiN committed Aug 5, 2022
1 parent 704acaa commit 4c7e496
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
var (
ErrTimedOut = errors.New("execution timed out")

listTimeoutSeconds = int64(30)
executionFailedCounter = 0

debug = os.Getenv("DEBUG") == "true"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4c7e496

Please sign in to comment.