Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Adding pagination to ListOverlappingIPs to fix context deadline error. #438

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions pkg/storage/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,22 @@ func (i *Client) ListOverlappingIPs(ctx context.Context) ([]whereaboutsv1alpha1.
ctxWithTimeout, cancel := context.WithTimeout(ctx, storage.RequestTimeout)
defer cancel()

overlappingIPsList, err := i.client.WhereaboutsV1alpha1().OverlappingRangeIPReservations("").List(ctxWithTimeout, metav1.ListOptions{})
if err != nil {
return nil, err
listOptions := metav1.ListOptions{
Limit: 50,
}

return overlappingIPsList.Items, nil
var overlappingIPsList []whereaboutsv1alpha1.OverlappingRangeIPReservation
for {
overlappingIPs, err := i.client.WhereaboutsV1alpha1().OverlappingRangeIPReservations("").List(ctxWithTimeout, listOptions)
if err != nil {
return nil, err
}
overlappingIPsList = append(overlappingIPsList, overlappingIPs.Items...)
if overlappingIPs.Continue == "" {
break
}
listOptions.Continue = overlappingIPs.Continue
}
return overlappingIPsList, nil
}

func (i *Client) DeleteOverlappingIP(ctx context.Context, clusterWideIP *whereaboutsv1alpha1.OverlappingRangeIPReservation) error {
Expand Down