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

Allow cache to handle 5XX errors and retry 5 times #1337

Merged
merged 1 commit into from May 24, 2017

Conversation

foursixnine
Copy link
Member

No description provided.

@foursixnine
Copy link
Member Author

The hax0r in me of late 90's likes this PR.

@@ -129,6 +129,16 @@ sub download_asset {
$asset = undef;
}
}
elsif ($tx->res->code && $tx->res->code =~ /5[0-9]{2}/) {
Copy link
Member

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

Copy link
Member Author

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 :)

@@ -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--) {
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

It does :)

@codecov
Copy link

codecov bot commented May 23, 2017

Codecov Report

Merging #1337 into master will decrease coverage by 0.07%.
The diff coverage is 36.84%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
lib/OpenQA/Worker/Cache.pm 77.35% <36.84%> (-4.28%) ⬇️
lib/OpenQA/Worker/Jobs.pm 83.41% <0%> (-0.5%) ⬇️
lib/OpenQA/WebAPI/Controller/Running.pm 80.32% <0%> (+4.91%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c05c24...aea93ad. Read the comment docs.

@coolo coolo merged commit e99f320 into os-autoinst:master May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants