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
Allow cache to handle 5XX errors and retry 5 times #1337
Conversation
The hax0r in me of late 90's likes this PR. |
lib/OpenQA/Worker/Cache.pm
Outdated
@@ -129,6 +129,16 @@ sub download_asset { | |||
$asset = undef; | |||
} | |||
} | |||
elsif ($tx->res->code && $tx->res->code =~ /5[0-9]{2}/) { |
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.
You can use the is_server_error
method for this. http://mojolicious.org/perldoc/Mojo/Message/Response#is_server_error
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.
is_server_error did the trick, however no error code is provided for situations where the the webserver is down. I used 531 for that :)
lib/OpenQA/Worker/Cache.pm
Outdated
@@ -176,6 +186,16 @@ sub get_asset { | |||
next; | |||
} | |||
$ret = download_asset($job->{id}, lc($asset_type), $asset, ($result->{etag}) ? $result->{etag} : undef); | |||
if ($ret =~ /5[0-9]{2}/ && $n--) { |
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.
Couldn't the path returned by download_asset
contain a substring 5xx
? If plain numbers are safe perhaps anchoring the regex (/^5[0-9]{2}$/
) would work.
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.
It does :)
a7a9081
to
0c8311a
Compare
Codecov Report
@@ Coverage Diff @@
## master #1337 +/- ##
==========================================
- Coverage 87.01% 86.93% -0.08%
==========================================
Files 101 101
Lines 7392 7408 +16
==========================================
+ Hits 6432 6440 +8
- Misses 960 968 +8
Continue to review full report at Codecov.
|
0c8311a
to
aea93ad
Compare
No description provided.