Support push_destination:true in prepare
The fix for bug #1783204 only handled the upload logic in isolation, and didn't account for the whole prepare flow. This change completes push_destination:true support with the following changes: - container_images_prepare_multi, which is the heat parameter driven interface for prepare, use heat parameter LocalContainerRegistry as the registry IP, which is only set during undercloud install. This handles the case where registry discovery won't work because it is too early in the undercloud install process - container_images_prepare, which is the python library API for prepare, make the image registry substitution support push_destination:true. The discovery logic can be used here since this is only ever called after networking is configured on the undercloud Change-Id: Ia18c89a48ef0fd0f3021823c6049042ac5e78eb8 Related-Bug: #1783204 Closes-Bug: #1786521
This commit is contained in:
parent
336cd3c636
commit
5ba17936fb
@ -135,6 +135,12 @@ def container_images_prepare_multi(environment, roles_data, dry_run=False,
|
||||
for cip_entry in cip:
|
||||
mapping_args = cip_entry.get('set')
|
||||
push_destination = cip_entry.get('push_destination')
|
||||
# use the configured registry IP as the discovered registry
|
||||
# if it is available
|
||||
if push_destination and isinstance(push_destination, bool):
|
||||
local_registry_ip = pd.get('LocalContainerRegistry')
|
||||
if local_registry_ip:
|
||||
push_destination = '%s:8787' % local_registry_ip
|
||||
pull_source = cip_entry.get('pull_source')
|
||||
modify_role = cip_entry.get('modify_role')
|
||||
modify_vars = cip_entry.get('modify_vars')
|
||||
@ -286,6 +292,10 @@ def container_images_prepare(template_file=DEFAULT_TEMPLATE_FILE,
|
||||
if pull_source:
|
||||
entry['pull_source'] = pull_source
|
||||
if push_destination:
|
||||
# substitute discovered registry if push_destination is set to true
|
||||
if isinstance(push_destination, bool):
|
||||
push_destination = image_uploader.get_undercloud_registry()
|
||||
|
||||
entry['push_destination'] = push_destination
|
||||
# replace the host portion of the imagename with the
|
||||
# push_destination, since that is where they will be uploaded to
|
||||
|
@ -533,6 +533,40 @@ class TestPrepare(base.TestCase):
|
||||
)
|
||||
)
|
||||
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('tripleo_common.image.image_uploader.get_undercloud_registry')
|
||||
def test_prepare_push_dest_discover(self, mock_gur, mock_get):
|
||||
mock_gur.return_value = '192.0.2.0:8787'
|
||||
self.assertEqual({
|
||||
'container_images.yaml': [{
|
||||
'imagename': 'docker.io/t/p-nova-api:l',
|
||||
'push_destination': '192.0.2.0:8787',
|
||||
}],
|
||||
'environments/containers-default-parameters.yaml': {
|
||||
'DockerNovaApiImage':
|
||||
'192.0.2.0:8787/t/p-nova-api:l',
|
||||
'DockerNovaConfigImage':
|
||||
'192.0.2.0:8787/t/p-nova-api:l',
|
||||
'DockerNovaMetadataConfigImage':
|
||||
u'192.0.2.0:8787/t/p-nova-api:l',
|
||||
'DockerNovaMetadataImage':
|
||||
'192.0.2.0:8787/t/p-nova-api:l'
|
||||
}},
|
||||
kb.container_images_prepare(
|
||||
template_file=TEMPLATE_PATH,
|
||||
output_env_file=constants.CONTAINER_DEFAULTS_ENVIRONMENT,
|
||||
output_images_file='container_images.yaml',
|
||||
service_filter=['OS::TripleO::Services::NovaApi'],
|
||||
push_destination=True,
|
||||
mapping_args={
|
||||
'namespace': 'docker.io/t',
|
||||
'name_prefix': 'p',
|
||||
'name_suffix': '',
|
||||
'tag': 'l',
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@mock.patch('requests.get')
|
||||
def test_prepare_ceph(self, mock_get):
|
||||
self.assertEqual({
|
||||
@ -782,6 +816,7 @@ class TestPrepare(base.TestCase):
|
||||
}
|
||||
env = {
|
||||
'parameter_defaults': {
|
||||
'LocalContainerRegistry': '192.0.2.1',
|
||||
'ContainerImagePrepare': [{
|
||||
'set': mapping_args,
|
||||
'tag_from_label': 'foo',
|
||||
@ -790,7 +825,7 @@ class TestPrepare(base.TestCase):
|
||||
'set': mapping_args,
|
||||
'tag_from_label': 'bar',
|
||||
'excludes': ['nova', 'neutron'],
|
||||
'push_destination': '192.0.2.1:8787',
|
||||
'push_destination': True,
|
||||
'modify_role': 'add-foo-plugin',
|
||||
'modify_only_with_labels': ['kolla_version'],
|
||||
'modify_vars': {'foo_version': '1.0.1'}
|
||||
|
Loading…
x
Reference in New Issue
Block a user