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

feat(konnect): introduce backoff strategy for config updates #3989

Merged
merged 5 commits into from
May 15, 2023

Conversation

czeslavo
Copy link
Contributor

@czeslavo czeslavo commented May 11, 2023

What this PR does / why we need it:

It introduces the concept of UpdateBackoffStrategy that can be used to decorate any UpdateStrategy with a custom backoff behavior. It implements such one (KonnectBackoffStrategy) for adminapi.KonnectClient and decorates its UpdateStrategy with that every time it's created.

The reason for introducing this is to prevent KIC from issuing too many requests to Konnect APIs when the configuration it tries to push is broken due to client-side faults such as e.g. duplicate IDs of entities.

Konnect's backoff strategy is composed of two requirements that both have to be satisfied to perform an Update action:

  • standard exponential backoff (with the initial interval of 3s and max of 15m) period has passed (increases every time Update fails)
  • config hash we attempt to push is not equal to the hash of a configuration that failed to be pushed in the past

Which issue this PR fixes:

Should fix #3959.

Special notes for your reviewer:

This implementation doesn't take into account Retry-After header that Konnect may return when we hit 429 as it wasn't possible to inspect headers on KIC level. We can consider extending the kong.APIError with details for the specific status codes, allowing us to convey the retry-after value in that.

Nevertheless, the backoff itself should save us from exceeding the API calls limits on Konnect side in the case of a faulty configuration.

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

@czeslavo czeslavo added area/feature New feature or request area/konnect Issues and PRs related to Konnect labels May 11, 2023
@czeslavo czeslavo added this to the KIC v2.10.0 milestone May 11, 2023
@czeslavo czeslavo self-assigned this May 11, 2023
@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Patch coverage: 90.3% and project coverage change: -0.5 ⚠️

Comparison is base (420f02a) 59.5% compared to head (9d9d1cb) 59.1%.

❗ Current head 9d9d1cb differs from pull request most recent head 643ac6e. Consider uploading reports for the commit 643ac6e to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3989     +/-   ##
=======================================
- Coverage   59.5%   59.1%   -0.5%     
=======================================
  Files        145     145             
  Lines      16125   16136     +11     
=======================================
- Hits        9603    9540     -63     
- Misses      5889    5964     +75     
+ Partials     633     632      -1     
Impacted Files Coverage Δ
internal/adminapi/konnect.go 0.0% <0.0%> (ø)
internal/dataplane/sendconfig/sendconfig.go 78.0% <62.5%> (-2.6%) ⬇️
internal/dataplane/sendconfig/backoff_strategy.go 78.5% <78.5%> (ø)
internal/dataplane/kong_client.go 61.2% <82.6%> (-0.1%) ⬇️
internal/adminapi/client.go 44.6% <83.3%> (+0.8%) ⬆️
internal/adminapi/backoff_strategy_konnect.go 98.5% <98.5%> (ø)
internal/clients/manager.go 94.6% <100.0%> (-0.3%) ⬇️
internal/dataplane/deckerrors/api.go 100.0% <100.0%> (ø)
internal/dataplane/sendconfig/dbmode.go 69.3% <100.0%> (+1.3%) ⬆️
internal/dataplane/sendconfig/inmemory.go 89.2% <100.0%> (+0.8%) ⬆️
... and 1 more

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@czeslavo czeslavo force-pushed the backoff-konnect branch 6 times, most recently from 0e05c45 to f43da1f Compare May 11, 2023 16:44
@czeslavo czeslavo marked this pull request as ready for review May 11, 2023 17:35
@czeslavo czeslavo requested a review from a team as a code owner May 11, 2023 17:35
@czeslavo czeslavo added the ci/run-e2e Trigger e2e test run from PR label May 11, 2023
@team-k8s-bot
Copy link
Collaborator

@team-k8s-bot team-k8s-bot removed the ci/run-e2e Trigger e2e test run from PR label May 11, 2023
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
@team-k8s-bot team-k8s-bot temporarily deployed to gcloud May 11, 2023 19:58 — with GitHub Actions Inactive
Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

Just some minor comments

internal/dataplane/sendconfig/backoff_strategy_test.go Outdated Show resolved Hide resolved
internal/adminapi/backoff_strategy_konnect.go Outdated Show resolved Hide resolved
internal/adminapi/backoff_strategy_konnect.go Outdated Show resolved Hide resolved
internal/dataplane/sendconfig/backoff_strategy.go Outdated Show resolved Hide resolved
@czeslavo czeslavo force-pushed the backoff-konnect branch 5 times, most recently from 8db13b7 to 9d9d1cb Compare May 12, 2023 16:32
@czeslavo czeslavo requested a review from pmalek May 12, 2023 16:33
Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

Minor nits. Otherwise 🚢

internal/adminapi/backoff_strategy_konnect.go Outdated Show resolved Hide resolved
internal/adminapi/client.go Outdated Show resolved Hide resolved
internal/dataplane/kong_client.go Outdated Show resolved Hide resolved
@czeslavo czeslavo requested a review from pmalek May 15, 2023 14:22
@czeslavo czeslavo merged commit 050e1f4 into main May 15, 2023
@czeslavo czeslavo deleted the backoff-konnect branch May 15, 2023 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/feature New feature or request area/konnect Issues and PRs related to Konnect size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Konnect push fails instead of throttling on HTTP 429
3 participants