Avoid an error in the fallback script when a fallback doesn't have any uptime

Sometimes, the fallback generation script doesn't add attributes to the
fallbacks in the list. If this happens, log an error, and avoid selecting
that fallback.

This is a rare issue: it should not change selection behaviour.

Fixes issue #20945.
This commit is contained in:
teor 2016-12-11 22:47:00 +11:00
parent 654367f026
commit 53ec087450
No known key found for this signature in database
GPG Key ID: 450CBA7F968F094B
2 changed files with 38 additions and 31 deletions

View File

@ -33,3 +33,5 @@
OnionOO. When a relay operator has multiple relays, this prioritises
relays that are up over relays that are down.
Closes ticket #20926; bugfix on 0.2.8.3-alpha.
- Stop failing when a relay has no uptime data in updateFallbackDirs.py.
Closes ticket 20945; bugfix on tor-0.2.8.1-alpha.

View File

@ -862,6 +862,7 @@ class Candidate(object):
self._badexit = self._avg_generic_history(badexit) / ONIONOO_SCALE_ONE
def is_candidate(self):
try:
if (MUST_BE_RUNNING_NOW and not self.is_running()):
logging.info('%s not a candidate: not running now, unable to check ' +
'DirPort consensus download', self._fpr)
@ -894,6 +895,10 @@ class Candidate(object):
or self._data['consensus_weight'] < 1):
logging.info('%s not a candidate: consensus weight invalid', self._fpr)
return False
except BaseException as e:
logging.warning("Exception %s when checking if fallback is a candidate",
str(e))
return False
return True
def is_in_whitelist(self, relaylist):