Over 1200 API call limit not reset after 5 minutes

Created on 23 August 2024, about 1 year ago

Problem/Motivation

After the Cloudflare 5 minute rate limit is exceeded, the API call count does not get reset after 5 minutes has passed. It stays at 1200, and no further Cloudflare purges are possible.

Steps to reproduce

  1. In a test environment, exceed the 5 minute API call limit. See that further attempts to purge result in logging the error, "ERROR: CloudFlare - Api Rate limit check.: Exceeded Api limit of 1200/1200 limit purges/day." Note, this error message is misleading because the limit is not per day but per 5 minutes.
  2. In the Admin UI, go to Configuration -> Development -> Performance -> Purge
  3. Expand "Queue" on the left.
  4. Under the "Queue" column, click the dropdown for "Database".
  5. Select "Empty" and confirm that you want to empty the queue.
  6. Wait 5 minutes, and run purge again. See that no further calls to Cloudflare purge API are made. Instead you continue to see the "Exceeded Api limit of 1200/1200 limit" message logged.

Proposed resolution

Find out where the cloudflarepurger submodule determines whether or not to reset the 5-minute API count, debug, and fix the logic. Then submit a patch.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States anthonyf

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @anthonyf
  • 🇺🇸United States anthonyf

    Adding a patch file. Automated tests for the cloudflarepurger submodule passed. I still need to do end-to-end testing on a site that has Cloudflare purging enabled.

  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States anthonyf

    I've completed my end-to-end testing on a site with Cloudflare purge enabled. The 5-minute rate limit functionality is working as expected now. The patch for this ticket is ready for review and testing by the community.

  • Pipeline finished with Failed
    about 1 year ago
    Total: 178s
    #268427
  • 🇳🇿New Zealand RoSk0 Wellington

    API rate reset happens in the \Drupal\cloudflare\State::incrementApiRateCount(). Cloudflare API state tracking has pretty good test coverage so please start with the test which would highlight the bug.

    However I'm not sure that there is a value in it counting recent changes in the API limits actively discussed in Raise cache tag purge limit Needs work .

  • 🇧🇷Brazil dungahk Balneário Camboriú

    I understand the fact that the changes being discussed on https://www.drupal.org/project/cloudflare/issues/3062379 Raise cache tag purge limit Needs work can make the API Rate Limit check obsolete, but this is still an issue impacting production websites.

    While the patch works, I feel like this is not the best way to fix the issue, it's introducing duplicated code, which can be a bit more difficult to maintain in the future.

    I'll try to create a merge request with an improved version of it.

    The other options I see are to completely remove the check or add a configuration option to disable it. As things stand, there is no way to do any of those without a patch.

    For me, the ideal scenario would be to resolve this issue while https://www.drupal.org/project/cloudflare/issues/3062379 Raise cache tag purge limit Needs work is being discussed.

  • Issue was unassigned.
  • Status changed to Active 11 days ago
  • Pipeline finished with Failed
    11 days ago
    Total: 405s
    #617219
  • Pipeline finished with Failed
    11 days ago
    Total: 182s
    #617259
  • Pipeline finished with Failed
    11 days ago
    Total: 174s
    #617292
Production build 0.71.5 2024