Merge "Ensure atomic inventory file rename runs on the same mountpoint"

This commit is contained in:
Zuul 2020-08-21 03:36:57 +00:00 committed by Gerrit Code Review
commit bebf95527b
2 changed files with 10 additions and 2 deletions

View File

@ -129,7 +129,11 @@ class TripleoInventories(object):
inventory[var]['vars'].update(value)
# Atomic update as concurrent tripleoclient commands can call this
with tempfile.NamedTemporaryFile('w', delete=False) as inventory_file:
inventory_file_dir = os.path.dirname(inventory_file_path)
with tempfile.NamedTemporaryFile(
'w',
dir=inventory_file_dir,
delete=False) as inventory_file:
yaml.dump(inventory, inventory_file, TemplateDumper)
os.rename(inventory_file.name, inventory_file_path)

View File

@ -379,7 +379,11 @@ class TripleoInventory(object):
inventory[var]['vars'].update(value)
# Atomic update as concurrent tripleoclient commands can call this
with tempfile.NamedTemporaryFile('w', delete=False) as inventory_file:
inventory_file_dir = os.path.dirname(inventory_file_path)
with tempfile.NamedTemporaryFile(
'w',
dir=inventory_file_dir,
delete=False) as inventory_file:
yaml.dump(inventory, inventory_file, TemplateDumper)
os.rename(inventory_file.name, inventory_file_path)