Commit f51aaa47 authored by Paul Graydon's avatar Paul Graydon

slapos/cli: Nicer error messages for cachelookup binary-sr

parent cc4a6ab3
......@@ -34,6 +34,8 @@ import sys
import prettytable
from six.moves.urllib.error import HTTPError
from slapos.grid import networkcache
from slapos.cli.config import ConfigCommand
from slapos.util import str2bytes
......@@ -88,6 +90,13 @@ def do_lookup(logger, cache_dir, cache_url, signature_certificate_list,
try:
entries = networkcache.download_entry_list(cache_url, cache_dir,
md5, logger, signature_certificate_list)
except HTTPError as e:
if e.code == 404:
logger.info('Software release not found in binary cache: %s', software_url)
else:
logger.critical('Problem occurred while connecting to shacache.',
exc_info=True)
return 1
except Exception:
logger.critical('Error while looking object %s', software_url,
exc_info=True)
......
......@@ -141,8 +141,8 @@ class TestCliCacheBinarySr(CliMixin):
software_url="this_is_uncached_url",
signature_certificate_list=self.sign_cert_list))
self.logger.critical.assert_any_call(
'Error while looking object %s', 'this_is_uncached_url', exc_info=True)
self.logger.info.assert_any_call(
'Software release not found in binary cache: this_is_uncached_url')
def test_bad_cache_dir(self):
self.assertEqual(1, cache_binarysr_do_lookup(
......
Markdown is supported
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