Commit 1667e592 authored by juga's avatar juga
Browse files

new: destination: Add configuration option

for the maximum number of failures before the destination is
not functional.

Part of #29589.
parent 083e7c70
......@@ -25,6 +25,10 @@ verify = False
# Use ZZ if the location is unknown (for instance, a CDN).
country = ZZ
# Number of consecutive times that a destination could not be used to measure
# before stopping to try to use it for a while that by default is 3h.
max_num_failures = 3
## The following logging options are set by default.
## There is no need to change them unless other options are prefered.
; [logging]
......
......@@ -286,7 +286,15 @@ class Destination:
assert 'url' in conf_section
url = conf_section['url']
verify = _parse_verify_option(conf_section)
return Destination(url, max_dl, verify)
try:
max_num_failures = conf_section.getint('max_num_failures')
except ValueError:
log.warning("Configuration max_num_failures is wrong, ignoring.")
max_num_failures = None
if max_num_failures:
return Destination(url, max_dl, verify, max_num_failures)
else:
return Destination(url, max_dl, verify)
class DestinationList:
......
......@@ -406,14 +406,16 @@ def _validate_destinations(conf):
urls = {
'url': {},
}
all_valid_keys = list(urls.keys()) + ['verify', 'country']
all_valid_keys = list(urls.keys()) \
+ ['verify', 'country', 'max_num_failures']
for sec in dest_sections:
if sec not in conf:
errors.append('{} is an enabled destination but is not a '
'section in the config'.format(sec))
continue
errors.extend(_validate_section_keys(
conf, sec, all_valid_keys, err_tmpl, allow_missing=['verify']))
conf, sec, all_valid_keys, err_tmpl,
allow_missing=['verify', 'max_num_failures']))
errors.extend(_validate_section_urls(conf, sec, urls, err_tmpl))
errors.extend(_validate_country(conf, sec, 'country', err_tmpl))
return errors
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment