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

Circumvent the rate limits on the API requests #65

Merged
merged 6 commits into from Nov 21, 2023
Merged

Circumvent the rate limits on the API requests #65

merged 6 commits into from Nov 21, 2023

Conversation

gridhead
Copy link
Member

Circumvent the rate limits on the API requests

Fixes #10, #33 and #60

Signed-off-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
@gridhead gridhead added the bug Something isn't working label Nov 20, 2023
@gridhead gridhead self-assigned this Nov 20, 2023
@gridhead
Copy link
Member Author

Here's a test where I set the rate limit of the API requests to 5.

If you like those colours, this is how it would end up looking like.

image

Here's the colourless variant otherwise.

(venv) [archdesk@archdesk pagure-exporter]$ pagure-exporter -s $TEST_SRCE -d $TEST_DEST -p $TEST_PKEY -g $TEST_GKEY -f $TEST_FUSR -t $TEST_FUSR tkts -s FULL -cla
[2023-11-21 12:58:19 +0530] [ BUSY ] Requesting for source namespace metadata...
[2023-11-21 12:58:20 +0530] [ PASS ] Source namespace metadata acquisition succeeded!
[2023-11-21 12:58:20 +0530]          Name: protop2g-test-srce
[2023-11-21 12:58:20 +0530]          Identifier: 17042
[2023-11-21 12:58:20 +0530]          Maintainer: Akashdeep Dhar (ID t0xic0der)
[2023-11-21 12:58:20 +0530]          Location: https://pagure.io/protop2g-test-srce
[2023-11-21 12:58:20 +0530]          Address: https://t0xic0der:****************************************************************@pagure.io/protop2g-test-srce.git
[2023-11-21 12:58:20 +0530]          Created on: Fri Oct 13 09:04:23 2023
[2023-11-21 12:58:20 +0530]          Last modified on: Fri Oct 13 09:04:23 2023
[2023-11-21 12:58:20 +0530]          Tags: []
[2023-11-21 12:58:21 +0530] [ BUSY ] Requesting for destination namespace metadata...
[2023-11-21 12:58:21 +0530] [ PASS ] Destination namespace metadata acquisition succeeded!
[2023-11-21 12:58:21 +0530]          Name: gridhead/protop2g-test
[2023-11-21 12:58:21 +0530]          Identifier: 42823949
[2023-11-21 12:58:21 +0530]          Maintainer: gridhead (ID Akashdeep Dhar)
[2023-11-21 12:58:21 +0530]          Location: https://gitlab.com/gridhead/protop2g-test
[2023-11-21 12:58:21 +0530]          Address: https://t0xic0der:**************************@gitlab.com/gridhead/protop2g-test.git
[2023-11-21 12:58:21 +0530]          Created on: 2023-01-23T16:18:30.217Z
[2023-11-21 12:58:21 +0530]          Last modified on: 2023-11-20T19:13:58.026Z
[2023-11-21 12:58:21 +0530]          Tags: []
[2023-11-21 12:58:21 +0530] [ BUSY ] Attempting source namespace issue ticket count...
[2023-11-21 12:58:21 +0530] [ WARN ] Extracting all issue tickets with labels, with states and with comments off the given selection
[2023-11-21 12:58:21 +0530]          Found 2 issue ticket(s) across 1 page(s) in 0.86 second(s)
[2023-11-21 12:58:21 +0530] [ BUSY ] Reading issue tickets information (Page 1 of 1)...
[2023-11-21 12:58:23 +0530]          Found 2 issue ticket(s) on this page in 1.56 second(s)
[2023-11-21 12:58:24 +0530] [ BUSY ] Migrating issue ticket with labels #2 'This is the title of the second test issue' by 'Akashdeep Dhar (ID t0xic0der)'...
[2023-11-21 12:58:24 +0530]          Migrated to https://gitlab.com/gridhead/protop2g-test/-/issues/3009 in 0.99 second(s)
[2023-11-21 12:58:24 +0530] [ BUSY ] Asserting issue ticket status...
[2023-11-21 12:58:25 +0530]          Asserted CLOSE status of the ticket in 0.64 second(s)
[2023-11-21 12:58:25 +0530] [ BUSY ] Reading comment information...
[2023-11-21 12:58:25 +0530]          Found 4 entities in 0.00 second(s)
[2023-11-21 12:58:25 +0530] [ BUSY ] Transferring comment (Entity 1 of 4)...
[2023-11-21 12:58:25 +0530]          Transferred to https://gitlab.com/gridhead/protop2g-test/-/issues/3009#note_1659503552 in 0.80 second(s)
[2023-11-21 12:58:27 +0530] [ BUSY ] Transferring comment (Entity 2 of 4)...
[2023-11-21 12:58:27 +0530]          Transferred to https://gitlab.com/gridhead/protop2g-test/-/issues/3009#note_1659503567 in 1.22 second(s)
[2023-11-21 12:58:27 +0530] [ BUSY ] Transferring comment (Entity 3 of 4)...
[2023-11-21 12:58:27 +0530]          Transferred to https://gitlab.com/gridhead/protop2g-test/-/issues/3009#note_1659503587 in 0.74 second(s)
[2023-11-21 12:58:27 +0530] [ WARN ] Rate limit reached - 5 API requests made...
[2023-11-21 12:58:27 +0530]          Waiting for 60 second(s) and resetting the counter before resuming the transfer process
[2023-11-21 12:59:28 +0530] [ BUSY ] Transferring comment (Entity 4 of 4)...
[2023-11-21 12:59:28 +0530]          Transferred to https://gitlab.com/gridhead/protop2g-test/-/issues/3009#note_1659505079 in 0.70 second(s)
[2023-11-21 12:59:29 +0530] [ BUSY ] Migrating issue ticket with labels #1 'This is the title of the first test issue' by 'Akashdeep Dhar (ID t0xic0der)'...
[2023-11-21 12:59:29 +0530]          Migrated to https://gitlab.com/gridhead/protop2g-test/-/issues/3010 in 1.29 second(s)
[2023-11-21 12:59:29 +0530] [ BUSY ] Asserting issue ticket status...
[2023-11-21 12:59:29 +0530]          Assertion unnecessary due to the OPEN status of the ticket
[2023-11-21 12:59:29 +0530] [ BUSY ] Reading comment information...
[2023-11-21 12:59:29 +0530]          Found 3 entities in 0.00 second(s)
[2023-11-21 12:59:30 +0530] [ BUSY ] Transferring comment (Entity 1 of 3)...
[2023-11-21 12:59:30 +0530]          Transferred to https://gitlab.com/gridhead/protop2g-test/-/issues/3010#note_1659505118 in 0.93 second(s)
[2023-11-21 12:59:31 +0530] [ BUSY ] Transferring comment (Entity 2 of 3)...
[2023-11-21 12:59:31 +0530]          Transferred to https://gitlab.com/gridhead/protop2g-test/-/issues/3010#note_1659505135 in 0.70 second(s)
[2023-11-21 12:59:31 +0530] [ WARN ] Rate limit reached - 5 API requests made...
[2023-11-21 12:59:31 +0530]          Waiting for 60 second(s) and resetting the counter before resuming the transfer process
[2023-11-21 01:00:32 +0530] [ BUSY ] Transferring comment (Entity 3 of 3)...
[2023-11-21 01:00:32 +0530]          Transferred to https://gitlab.com/gridhead/protop2g-test/-/issues/3010#note_1659505922 in 0.77 second(s)
[2023-11-21 01:00:32 +0530] [ PASS ] Namespace assets transferring queue processed!
[2023-11-21 01:00:32 +0530]          2 issue ticket(s) transferred
(venv) [archdesk@archdesk pagure-exporter]$ 

While you are free to review this pull request, please note that I have yet to write some test cases for the newly added functionality so this pull request cannot be merged yet.

@gridhead gridhead force-pushed the ratecirc branch 2 times, most recently from 451d290 to 7d3beeb Compare November 20, 2023 19:43
Signed-off-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
This stalls the transfer for the time period proposed in the standard configuration (which is 60 by default) and resets the index counter to 0 when it reaches the amount proposed in the standard configuration (which is 500 by default)

Signed-off-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
For any HTTP request of type POST or PUT, the index counter is incremented by 1 to ensure that the attempts are kept track of to compare against the maximum possible number of attempts required to break the rate limit on the API requests

Signed-off-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
@gridhead
Copy link
Member Author

@Zlopez and @jwflory, reviews appreciated :)

Also removed a stray `print()` command that I previously added for debugging

Signed-off-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
Copy link

@samyak-jn samyak-jn left a comment

Choose a reason for hiding this comment

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

Hello @gridhead 👋

Thanks for working on this. verified most of the files consists of license description renaming which is good; otherwise the callwait functions seems right to me along with a supported testcase, so here's my +1 to this.

Signed-off-by: Akashdeep Dhar <akashdeep.dhar@gmail.com>
@gridhead
Copy link
Member Author

Apart from a couple of hiccups in between (reported in #66 and #67), my attempt to transfer issue tickets of all states (irrespective of OPEN or SHUT) along with their comments and states from the pagure.io/fedora-commops repository turned out to be successful.

Here are some tickets to confirm the success of such a long-winded transfer https://gitlab.com/gridhead/protop2g-test/-/issues/3609, https://gitlab.com/gridhead/protop2g-test/-/issues/3606, https://gitlab.com/gridhead/protop2g-test/-/issues/3603, https://gitlab.com/gridhead/protop2g-test/-/issues/3600, https://gitlab.com/gridhead/protop2g-test/-/issues/3557, https://gitlab.com/gridhead/protop2g-test/-/issues/3554 and https://gitlab.com/gridhead/protop2g-test/-/issues/3551.

Here's the complete result.

image

Here's where it is shown that the tool takes a pause for 60 seconds after having made 195 requests before continuing on to do some more.

image

@gridhead
Copy link
Member Author

Thanks for the review, @samyak-jn!

@gridhead gridhead merged commit 71622dd into main Nov 21, 2023
4 checks passed
@gridhead gridhead deleted the ratecirc branch November 21, 2023 14:28
gridhead added a commit that referenced this pull request Dec 13, 2023
Circumvent the rate limits on the API requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants