Commit f51aaa47 authored by Paul Graydon's avatar Paul Graydon

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

parent cc4a6ab3
Pipeline #37585 failed with stage
in 0 seconds
...@@ -34,6 +34,8 @@ import sys ...@@ -34,6 +34,8 @@ import sys
import prettytable import prettytable
from six.moves.urllib.error import HTTPError
from slapos.grid import networkcache from slapos.grid import networkcache
from slapos.cli.config import ConfigCommand from slapos.cli.config import ConfigCommand
from slapos.util import str2bytes from slapos.util import str2bytes
...@@ -88,6 +90,13 @@ def do_lookup(logger, cache_dir, cache_url, signature_certificate_list, ...@@ -88,6 +90,13 @@ def do_lookup(logger, cache_dir, cache_url, signature_certificate_list,
try: try:
entries = networkcache.download_entry_list(cache_url, cache_dir, entries = networkcache.download_entry_list(cache_url, cache_dir,
md5, logger, signature_certificate_list) 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: except Exception:
logger.critical('Error while looking object %s', software_url, logger.critical('Error while looking object %s', software_url,
exc_info=True) exc_info=True)
......
...@@ -141,8 +141,8 @@ class TestCliCacheBinarySr(CliMixin): ...@@ -141,8 +141,8 @@ class TestCliCacheBinarySr(CliMixin):
software_url="this_is_uncached_url", software_url="this_is_uncached_url",
signature_certificate_list=self.sign_cert_list)) signature_certificate_list=self.sign_cert_list))
self.logger.critical.assert_any_call( self.logger.info.assert_any_call(
'Error while looking object %s', 'this_is_uncached_url', exc_info=True) 'Software release not found in binary cache: this_is_uncached_url')
def test_bad_cache_dir(self): def test_bad_cache_dir(self):
self.assertEqual(1, cache_binarysr_do_lookup( 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