Merge "Don't delete container_cidr key when overriding"

This commit is contained in:
Jenkins 2016-12-13 20:30:57 +00:00 committed by Gerrit Code Review
commit a3c8f8f7b5
3 changed files with 39 additions and 1 deletions

View File

@ -793,9 +793,12 @@ def _parse_global_variables(user_cidr, inventory, user_defined_config):
)
logger.debug("Applied global_overrides")
kept_vars = user_defined_config['global_overrides'].keys()
kept_vars.append('container_cidr')
# Remove global overrides that were deleted from inventory, too
for key in inventory['all']['vars'].keys():
if key not in user_defined_config['global_overrides']:
if key not in kept_vars:
logger.debug("Deleting key %s from inventory", key)
del inventory['all']['vars'][key]

View File

@ -0,0 +1,8 @@
---
fixes:
- The 'container_cidr' key has been restored back to openstack_inventory.json
The fix to remove deleted global override keys mistakenly deleted the
'container_cidr' key, as well. This was used by downstream consumers,
and cannot be reconstructed with other information inside the inventory
file. Regression tests were also added.

View File

@ -832,6 +832,33 @@ class TestGlobalOverridesConfigDeletion(TestConfigCheckBase):
self.assertEqual('bar', self.inventory['all']['vars']['foo'])
def test_container_cidr_key_retained(self):
user_cidr = self.user_defined_config['cidr_networks']['container']
di._parse_global_variables(user_cidr, self.inventory,
self.user_defined_config)
self.assertIn('container_cidr', self.inventory['all']['vars'])
self.assertEqual(self.inventory['all']['vars']['container_cidr'],
user_cidr)
def test_only_old_vars_deleted(self):
self.inventory['all']['vars']['foo'] = 'bar'
di._parse_global_variables('', self.inventory,
self.user_defined_config)
self.assertNotIn('foo', self.inventory['all']['vars'])
def test_empty_vars(self):
del self.inventory['all']
di._parse_global_variables('', self.inventory,
self.user_defined_config)
self.assertIn('container_cidr', self.inventory['all']['vars'])
for key in self.user_defined_config['global_overrides']:
self.assertIn(key, self.inventory['all']['vars'])
class TestEnsureInventoryUptoDate(unittest.TestCase):
def setUp(self):