Ensure glance-registry-paste.ini exists for <= Q
Change-Id: I84360db1522b735a20f4141235b111700935fe58 Closes-Bug: #1812972
This commit is contained in:
parent
c9f44a7cec
commit
160e5d2d9f
@ -539,12 +539,18 @@ def reinstall_paste_ini(force_reinstall=False):
|
||||
is set to True.
|
||||
'''
|
||||
db = kv()
|
||||
if not db.get(PASTE_INI_MARKER) or force_reinstall:
|
||||
reinstall = not db.get(PASTE_INI_MARKER) or force_reinstall
|
||||
cmp_release = CompareOpenStackReleases(os_release('glance-common'))
|
||||
|
||||
if not os.path.exists(GLANCE_REGISTRY_PASTE) and cmp_release < 'rocky':
|
||||
# See LP: #1812972
|
||||
reinstall = True
|
||||
|
||||
if reinstall:
|
||||
for paste_file in [GLANCE_REGISTRY_PASTE,
|
||||
GLANCE_API_PASTE]:
|
||||
if os.path.exists(paste_file):
|
||||
os.remove(paste_file)
|
||||
cmp_release = CompareOpenStackReleases(os_release('glance-common'))
|
||||
# glance-registry is deprecated at queens but still
|
||||
# installed.
|
||||
if cmp_release < 'rocky':
|
||||
|
@ -385,15 +385,33 @@ class TestGlanceUtils(CharmTestCase):
|
||||
fatal=True
|
||||
)
|
||||
|
||||
@patch.object(os.path, 'exists')
|
||||
@patch.object(utils, 'os_release')
|
||||
@patch.object(utils, 'kv')
|
||||
def test_reinstall_paste_ini_idempotent(self, kv):
|
||||
def test_reinstall_paste_ini_idempotent(self, kv, mock_os_release,
|
||||
mock_exists):
|
||||
"""Ensure that re-running does not re-install files"""
|
||||
mock_exists.return_value = True
|
||||
mock_os_release.return_value = "queens"
|
||||
test_kv = SimpleKV()
|
||||
test_kv.set(utils.PASTE_INI_MARKER, True)
|
||||
kv.return_value = test_kv
|
||||
utils.reinstall_paste_ini()
|
||||
self.assertFalse(self.apt_install.called)
|
||||
|
||||
@patch.object(os.path, 'exists')
|
||||
@patch.object(utils, 'os_release')
|
||||
@patch.object(utils, 'kv')
|
||||
def test_reinstall_paste_ini_fix_upgrade(self, kv, mock_os_release,
|
||||
mock_exists):
|
||||
mock_exists.return_value = False
|
||||
mock_os_release.return_value = "queens"
|
||||
test_kv = SimpleKV()
|
||||
test_kv.set(utils.PASTE_INI_MARKER, True)
|
||||
kv.return_value = test_kv
|
||||
utils.reinstall_paste_ini()
|
||||
self.assertTrue(self.apt_install.called)
|
||||
|
||||
def _test_is_api_ready(self, tgt):
|
||||
fake_config = MagicMock()
|
||||
with patch.object(utils, 'incomplete_relation_data') as ird:
|
||||
|
Loading…
x
Reference in New Issue
Block a user