|
|
|
|
@ -194,13 +194,12 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) { |
|
|
|
|
events, err := d.client.ListEvents(ctx, &eventsOpts) |
|
|
|
|
if err != nil { |
|
|
|
|
var e *linodego.Error |
|
|
|
|
if errors.As(err, &e) && e.Code == http.StatusUnauthorized { |
|
|
|
|
// If we get a 401, the token doesn't have `events:read_only` scope.
|
|
|
|
|
// Disable event polling and fallback to doing a full refresh every interval.
|
|
|
|
|
d.eventPollingEnabled = false |
|
|
|
|
} else { |
|
|
|
|
if !(errors.As(err, &e) && e.Code == http.StatusUnauthorized) { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
// If we get a 401, the token doesn't have `events:read_only` scope.
|
|
|
|
|
// Disable event polling and fallback to doing a full refresh every interval.
|
|
|
|
|
d.eventPollingEnabled = false |
|
|
|
|
} else { |
|
|
|
|
// Event polling tells us changes the Linode API is aware of. Actions issued outside of the Linode API,
|
|
|
|
|
// such as issuing a `shutdown` at the VM's console instead of using the API to power off an instance,
|
|
|
|
|
|