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

Discovery poll: wait PollInterval between fetches #41768

Merged
merged 2 commits into from
May 21, 2024

Conversation

marcoandredinis
Copy link
Contributor

@marcoandredinis marcoandredinis commented May 20, 2024

Instead of using a time.Ticker which would fire at specific intervals, we are now using a time.Timer which will wait PollInterval duration between API fetches.

Previously, with a low PollInterval or with a slow fetchAndSubmit, we could be hammering the external API by immediately calling a new fetchAndSubmit right after ending the current one.

This changes ensures we wait at least the specified interval before starting a new iteration (unless a DiscoveryConfig is changed, in that case the polling starts immediately).

#41761 (comment)

case <-w.triggerFetchC:
// stop and drain timer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this near the reset

Instead of using a time.Ticker which would fire at specific intervals,
we are now using a time.Timer which will wait PollInterval duration
between API fetches.

Previously, with a low PollInterval or with a slow fetchAndSubmit, we
could be hamering the external API by immediatly calling a new
fetchAndSubmit right after ending the current one.

This changes ensures we wait at least the specificied interval before
starting a new iteration (unless a DiscoveryConfig is changed, in that
case the polling starts immediatly).
@marcoandredinis marcoandredinis force-pushed the marco/discovery_timer-insteadof-ticker branch from e15be13 to d517d8f Compare May 21, 2024 07:08
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from lxea May 21, 2024 09:08
@marcoandredinis marcoandredinis added this pull request to the merge queue May 21, 2024
Merged via the queue into master with commit 2372645 May 21, 2024
37 checks passed
@marcoandredinis marcoandredinis deleted the marco/discovery_timer-insteadof-ticker branch May 21, 2024 09:28
@public-teleport-github-review-bot

@marcoandredinis See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Failed

marcoandredinis added a commit that referenced this pull request May 21, 2024
* Discovery poll: wait PollInterval between fetches

Instead of using a time.Ticker which would fire at specific intervals,
we are now using a time.Timer which will wait PollInterval duration
between API fetches.

Previously, with a low PollInterval or with a slow fetchAndSubmit, we
could be hamering the external API by immediatly calling a new
fetchAndSubmit right after ending the current one.

This changes ensures we wait at least the specificied interval before
starting a new iteration (unless a DiscoveryConfig is changed, in that
case the polling starts immediatly).

* move stop and drain closer to reset
marcoandredinis added a commit that referenced this pull request May 21, 2024
* Discovery poll: wait PollInterval between fetches

Instead of using a time.Ticker which would fire at specific intervals,
we are now using a time.Timer which will wait PollInterval duration
between API fetches.

Previously, with a low PollInterval or with a slow fetchAndSubmit, we
could be hamering the external API by immediatly calling a new
fetchAndSubmit right after ending the current one.

This changes ensures we wait at least the specificied interval before
starting a new iteration (unless a DiscoveryConfig is changed, in that
case the polling starts immediatly).

* move stop and drain closer to reset
github-merge-queue bot pushed a commit that referenced this pull request May 21, 2024
)

* Document DiscoveryService poll interval knob

* link to const instead of hard coding the default in godoc

* Discovery poll: wait PollInterval between fetches (#41768)

* Discovery poll: wait PollInterval between fetches

Instead of using a time.Ticker which would fire at specific intervals,
we are now using a time.Timer which will wait PollInterval duration
between API fetches.

Previously, with a low PollInterval or with a slow fetchAndSubmit, we
could be hamering the external API by immediatly calling a new
fetchAndSubmit right after ending the current one.

This changes ensures we wait at least the specificied interval before
starting a new iteration (unless a DiscoveryConfig is changed, in that
case the polling starts immediatly).

* move stop and drain closer to reset
github-merge-queue bot pushed a commit that referenced this pull request May 21, 2024
)

* Document DiscoveryService poll interval knob

* link to const instead of hard coding the default in godoc

* Discovery poll: wait PollInterval between fetches (#41768)

* Discovery poll: wait PollInterval between fetches

Instead of using a time.Ticker which would fire at specific intervals,
we are now using a time.Timer which will wait PollInterval duration
between API fetches.

Previously, with a low PollInterval or with a slow fetchAndSubmit, we
could be hamering the external API by immediatly calling a new
fetchAndSubmit right after ending the current one.

This changes ensures we wait at least the specificied interval before
starting a new iteration (unless a DiscoveryConfig is changed, in that
case the polling starts immediatly).

* move stop and drain closer to reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v14 backport/branch/v15 discovery no-changelog Indicates that a PR does not require a changelog entry size/sm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants