From 377bdffdbe07673e03f759aba3e54fbe1cd074e7 Mon Sep 17 00:00:00 2001 From: TJ Hoplock <33664289+tjhop@users.noreply.github.com> Date: Tue, 16 Nov 2021 18:02:27 -0500 Subject: [PATCH] feat: tune api requrest page sizes in linode SD (#9779) --- discovery/linode/linode.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/discovery/linode/linode.go b/discovery/linode/linode.go index fad2a74f1..a673b44c6 100644 --- a/discovery/linode/linode.go +++ b/discovery/linode/linode.go @@ -161,8 +161,12 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) { if d.lastResults != nil && d.eventPollingEnabled { // Check to see if there have been any events. If so, refresh our data. - opts := linodego.NewListOptions(1, fmt.Sprintf(filterTemplate, d.lastRefreshTimestamp.Format("2006-01-02T15:04:05"))) - events, err := d.client.ListEvents(ctx, opts) + opts := linodego.ListOptions{ + PageOptions: &linodego.PageOptions{Page: 1}, + PageSize: 25, + Filter: fmt.Sprintf(filterTemplate, d.lastRefreshTimestamp.Format("2006-01-02T15:04:05")), + } + events, err := d.client.ListEvents(ctx, &opts) if err != nil { var e *linodego.Error if errors.As(err, &e) && e.Code == http.StatusUnauthorized { @@ -205,13 +209,13 @@ func (d *Discovery) refreshData(ctx context.Context) ([]*targetgroup.Group, erro } // Gather all linode instances. - instances, err := d.client.ListInstances(ctx, &linodego.ListOptions{}) + instances, err := d.client.ListInstances(ctx, &linodego.ListOptions{PageSize: 500}) if err != nil { return nil, err } // Gather detailed IP address info for all IPs on all linode instances. - detailedIPs, err := d.client.ListIPAddresses(ctx, &linodego.ListOptions{}) + detailedIPs, err := d.client.ListIPAddresses(ctx, &linodego.ListOptions{PageSize: 500}) if err != nil { return nil, err }