Make sure we do not crash on pillars that are
not properly formatted.
@@ -40,9 +40,11 @@ def get_registries_certs(lst, default_port=5000):
LOG.debug('Finding certificates in: %s', lst)
for registry in lst:
+ try:
url = registry.get('url')
+
cert = registry.get('cert', '')
- if len(cert) > 0:
+ if cert:
# parse the name as an URL or "host:port", and return <HOST>[:<PORT>]
hostname, port = _get_hostname_and_port(url)
@@ -70,14 +72,21 @@ def get_registries_certs(lst, default_port=5000):
# the same happens if the user introduced a certificate for
# "my-registry": we must fix the "docker pull my-registry:5000/some/image" case...
name = hostname + ':' + str(default_port)
- LOG.debug('Adding certificate for default port, "%s", too', name)
+ LOG.debug(
+ 'Adding certificate for default port, "%s", too', name)
certs[name] = cert
+ except Exception as e:
+ LOG.error('Could not parse certificate: %s', e)
+
+ try:
mirrors = registry.get('mirrors', [])
- if len(mirrors) > 0:
+ if mirrors:
LOG.debug('Looking recursively for certificates in mirrors')
certs_mirrors = get_registries_certs(mirrors,
default_port=default_port)
certs.update(certs_mirrors)
+ except Exception as e:
+ LOG.error('Could not parse mirrors: %s', e)
return certs
