Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Make upload more robust by ignoring spurious errors while polling the scan status. #480
Conversation
snappy-m-o
commented
Apr 21, 2016
|
Can one of the admins verify this patch? |
snappy-m-o
commented
Apr 21, 2016
|
Can one of the admins verify this patch? |
sergiusens
reviewed
Apr 21, 2016
| + try: | ||
| + resp = session.get(url) | ||
| + return resp | ||
| + except (requests.ConnectionError, requests.HTTPError): |
sergiusens
Apr 21, 2016
Collaborator
What was HTTPError, will we loop forever if the resource does not exist?
vilagithub
Apr 22, 2016
Contributor
What was HTTPError
I don't remember encountering it in this particular case but the code involved can trigger it. I can remove it if you prefer.
will we loop forever if the resource does not exist?
No. The caller retries a fixed number of times and will report the last error.
elopio
reviewed
Apr 22, 2016
| + # level (is_scan_completed) will deal with the None response | ||
| + # meaning we don't know the status. This avoid a spurious | ||
| + # connection error breaking an upload for a wrong reason. | ||
| + return None |
elopio
Apr 22, 2016
Member
According to [1], we should return an exception instead of None. That makes sense because the name of the exception will make it's meaning clearer than None.
[1] https://www.goodreads.com/book/show/23020812-effective-python
vilagithub
Apr 22, 2016
Contributor
we should return an exception instead of None.
No, that's the bug. The caller (intermediate, hidden, out of our reach) can't catch it nor act properly. Returning None tells the caller: nah, not completed yet.
elopio
Apr 27, 2016
Member
I see, @retry doesn't let you handle the exception. The comments make this clear, so I'm ok with this.
elopio
reviewed
Apr 22, 2016
| + return False | ||
| + | ||
| + | ||
| +def get_scan_status(session, url): |
elopio
Apr 22, 2016
Member
I think I would name these helper funcions with a leading underscore, to make it clear that they are called only from higher level functions.
vilagithub
Apr 22, 2016
Contributor
There is a refactor in progress in another branch, I'd rather address that there ?
|
this looks good to me. It's good that you moved the func out of common, because it was called only once. |
|
retest this please |
|
From http://162.213.35.179:8080/job/github-snapcraft-autopkgtest-cloud/597/console So 30 minutes hanging on the instance creation. Re-test ? From http://162.213.35.179:8080/job/github-snapcraft-examples-tests-cloud/697/console 2016/04/27 16:31:55 *** Creating a Snappy m1.medium instance for release rolling, channel edge and image type custom *** goroutine 1 [running]: |
pushed a commit
to vilagithub/snapcraft
that referenced
this pull request
Apr 28, 2016
|
retest this |
|
OK to test |
|
Looks good to me |
vilagithub commentedApr 21, 2016
… scan status.
While the snap is scanned on the store, the status is polled until completion.
If an error occurs while acquiring the status, ignore the errors.
Those errors are rare and the next retry generally succeeds so ignoring those errors is harmless.
If they persist until the last retry, something else may be going on and this will still be reported.
LP: #1572963