Handle sparse resource registry in build_service_filter

During image prepare, the intent of build_service_filter is to filter
out services which are *known* to be not containerized, either because
they are puppet services, or have been mapped to 'OS::Heat::None'.

However if a partial resource registry is passed in, then this was
also filtering out the services with missing resource_registry
mappings. Since we're now assuming services are containerized by
default, this behaviour was cause many of the issues with missing or
no image parameters being generated.

Closes-Bug: #1727347
Change-Id: Ie65038e3ed73a77aeec9178231ab776ed26a2d84
(cherry picked from a26410ff9d)
This commit is contained in:
Steve Baker 2018-08-30 10:42:27 +12:00
parent bb0582a4f8
commit ea12e6994f
2 changed files with 11 additions and 7 deletions

View File

@ -93,19 +93,21 @@ def build_service_filter(environment, roles_data):
if not roles_data:
return None
enabled_services = get_enabled_services(environment, roles_data)
containerized_services = set()
resource_registry = environment.get('resource_registry')
if not resource_registry:
# no way to tell which services are containerized, so just filter by
# enabled services
# no way to tell which services are non-containerized, so
# filter by enabled services
return enabled_services
for service, env_path in environment.get('resource_registry', {}).items():
if not any(p in env_path for p in ['/puppet/services',
'OS::Heat::None']):
containerized_services.add(service)
if service not in enabled_services:
continue
if env_path == 'OS::Heat::None':
enabled_services.remove(service)
if '/puppet/services' in env_path:
enabled_services.remove(service)
return containerized_services.intersection(enabled_services)
return enabled_services
def container_images_prepare_multi(environment, roles_data, dry_run=False,

View File

@ -754,6 +754,7 @@ class TestPrepare(base.TestCase):
def test_build_service_filter(self):
self.assertEqual(
set([
'OS::TripleO::Services::HeatApi',
'OS::TripleO::Services::NovaApi',
'OS::TripleO::Services::NovaCompute',
'OS::TripleO::Services::OpenShift::Master',
@ -782,6 +783,7 @@ class TestPrepare(base.TestCase):
'name': 'Controller',
'CountDefault': 1,
'ServicesDefault': [
'OS::TripleO::Services::HeatApi',
'OS::TripleO::Services::NeutronApi',
'OS::TripleO::Services::NovaApi',
'OS::TripleO::Services::OpenShift::Master',