-
Notifications
You must be signed in to change notification settings - Fork 9
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
Update GlotPress export-translations
requests to avoid rate limiting
#361
Update GlotPress export-translations
requests to avoid rate limiting
#361
Conversation
This will avoid doubling up each request we make. More details at https://wordpress.slack.com/archives/C02RP50LK/p1651640726217119?thread_ts=1651607938.132789&cid=C02RP50LK
This way, people looking at the request logs (and machines, too, I hope) will know it is a legit source that's making the requests. The value originally suggested was `WordPress iOS App Release Packager; https://apps.wordpress.com/ ` but I chose a more generic one because this tooling is used for more than WordPress alone. See https://wordpress.slack.com/archives/C02RP50LK/p1651640726217119?thread_ts=1651607938.132789&cid=C02RP50LK
This will avoid doubling up each request we make. More details at https://wordpress.slack.com/archives/C02RP50LK/p1651640726217119?thread_ts=1651607938.132789&cid=C02RP50LK
…otPress This way, people looking at the request logs (and machines, too, I hope) will know it is a legit source that's making the requests. The value originally suggested was `WordPress iOS App Release Packager; https://apps.wordpress.com/ ` but I chose a more generic one because this tooling is used for more than WordPress alone. See https://wordpress.slack.com/archives/C02RP50LK/p1651640726217119?thread_ts=1651607938.132789&cid=C02RP50LK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While working and reviewing the code, the fact that the logic to build the URL is duplicated in several places clearly stood out to me. I decided not to refactor it to keep this fix focused and fast to review, given this is currently a blocking issue for at least the WordPress iOS release automation.
module Fastlane | ||
module Wpmreleasetoolkit | ||
USER_AGENT = 'Automattic App Release Automator; https://github.com/wordpress-mobile/release-toolkit/'.freeze | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this is the best way to define a constant scoped to the whole toolkit codebase. I copied this approach from version.rb
.
it 'sets a predefined User Agent so GlotPress will not rate-limit us' do | ||
# Arrange | ||
stub = stub_request(:get, "#{gp_fake_url}/fr/default/export-translations/") | ||
.with( | ||
query: { format: 'strings' }, | ||
# Note that the syntax below merely checks that the given headers are present in the request, | ||
# it does not restrict the request to have only those headers. | ||
# | ||
# See: | ||
# - https://github.com/bblimke/webmock/tree/33d8810c2828fc17010e15cc3f21ad2c726a966f#matching-requests | ||
# - https://github.com/bblimke/webmock/issues/276#issuecomment-28625436 | ||
headers: { 'User-Agent' => 'Automattic App Release Automator; https://github.com/wordpress-mobile/release-toolkit/' } | ||
).to_return(body: 'content') | ||
dest = StringIO.new | ||
# Act | ||
described_class.download_glotpress_export_file(project_url: gp_fake_url, locale: 'fr', filters: nil, destination: dest) | ||
# Assert | ||
expect(stub).to have_been_made.once | ||
expect(dest.string).to eq('content') | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: The android test has this example at the bottom, while here is at the top. I think we can live with that...
@AliSoftware this is still a draft, but I'd love to hear your thoughts on it. Thanks! I think the approach is on the right track. However... I tested it locally from WordPress iOS (using |
# Note that the syntax below merely checks that the given headers are present in the request, | ||
# it does not restrict the request to have only those headers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@mokagio Decided to go ahead and merge it because I need to do a hotfix (that has already been delayed a bit in last 2 days so I don't want to delay it more) which means that I'll also need to do a new beta (for Android That being said I'm indeed not sure that's enough for the server to not rate-limit us. Sure it will divide the requests by 2 by avoiding the intermediate redirect, but from my initial tests setting the User-Agent was still not reducing the rate limiting. So we'll still have to do some follow-up with folks who handle the server side of this. Some options I can imagine:
My main concern with all that is timing. We really have to find a solution to stop having those 429 soon, because we will definitively need them for the next betas we do, be it the one for localization testing next Wednesday… or more importantly, the final build at the end of the sprint. |
In hope to limit the risk of "429 Too Many Requests" errors when downloading the translations See wordpress-mobile/release-toolkit#361
For reference: https://make.wordpress.org/systems/2022/05/05/mobile-release-tools-unable-to-fetch-from-glotpress/ |
Left to do: Make the "Error downloading locale..." print the URL used for the download, to make it easier to triage.See #362.Starting yesterday, both I and @AliSoftware have been experiencing rate-liming when trying to download translations for the iOS app via this tooling:
I reached out in the WordPress.org Slack and the issue was identified as genuine rate-limiting applied to our requests (I still don't know why it started only recently, though).
@dd32 suggested in the WordPress.org Slack to:
This PR address the first two points. Regarding SSL, we don't have any specific dependency, so I'm guessing it's all up to the
URI.open
implementation from the Ruby runtime on which the tooling runs. We try to keep those fairly up to date. Our major apps are all on Ruby 2.7.4 (not the latest, but fairly recent still)