Fix overwriting downloaded config files

When we wrote downloaded config files over previously existing ones,
we sometimes got garbled files with remainders of the previous state,
e.g.:

step_4:
  keystone_refresh:
    action: exec
    command:
    - keystone
    - pkill
    - --signal
    - USR1
    - httpd
    start_order: 1
    user: root
start_order: 1
    user: root

This was because we opened the file for writing but didn't truncate
its size, so this commit adds O_TRUNC to the flags for opening
files. It's very similar to bug 1434187 which we had a long time ago.

Revert "Fix deploy health checks"
Depends-On: Ia2c12d7455564b6297c5f0934812b10fabbdc914

Change-Id: Ib1d3c68ec3c4048ffc7277daf84834288ea50e48
Closes-Bug: #1783866
This commit is contained in:
Jiri Stransky 2018-07-27 12:10:37 +02:00 committed by Quique Llorente
parent 1c32aa5f9e
commit f6767eb21c
1 changed files with 2 additions and 3 deletions

View File

@ -105,9 +105,8 @@ class Config(object):
@staticmethod
def _open_file(path):
return os.fdopen(os.open(path,
os.O_WRONLY | os.O_CREAT, 0o600),
'w')
return os.fdopen(
os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w')
def _write_playbook_get_tasks(self, tasks, role, filepath):
playbook = []