]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
cephadm: convert more temporary file writes to use write_new
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 6 Jun 2023 16:37:14 +0000 (12:37 -0400)
committerAdam King <adking@redhat.com>
Thu, 31 Aug 2023 17:35:13 +0000 (13:35 -0400)
commit327423651480d7202a8b9898b9a02219cf6aaed7
tree315893be8261b6d5e3ffbff68ebae39de8131f06
parent0a5832e8d70cc0107a9bacd71e717bafa8748357
cephadm: convert more temporary file writes to use write_new

Some functions are using the pattern:
```
with open(os.open(name + '.new, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
    f.write(...)
    os.rename(name + '.new', name)
```
While it is not entirely clear why this pattern was first used,
it accomplishes the same goal as `write_new` only directly calling
the posix open call. I analyzed the open flags for `write_new` and
these calls using `strace` and noted that the only significant
difference was the lack of O_TRUNC in these cases. Since the ".new"
files should not exist the lack of O_TRUC ought not make any difference.
With this decided we can convert these instances to `write_new`.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit 5845a758fde8def526f89b050f2b51e6b3458ddd)
src/cephadm/cephadm.py