]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
cephadm: convert SNMPGateway create_daemon_conf to use write_new
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 6 Jun 2023 17:16:29 +0000 (13:16 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 6 Jun 2023 18:24:06 +0000 (14:24 -0400)
commit6ec5a5ead36a79ce331b6943296c401feea7a896
tree53aafb0cf6282dfa417ec72449907896930f6bfc
parent5845a758fde8def526f89b050f2b51e6b3458ddd
cephadm: convert SNMPGateway create_daemon_conf to use write_new

While it is not entirely clear why this pattern of using os.open and
posix open flags instead of `open` directly was used I determined (using
strace) that the only major difference between these open flags and
those used by `open` was the lack of O_TRUNC. Unlike some other cases
this function does not use an intermediate temporary file.  This means
that if the file being written already exists and the data being written
is smaller then the remaining data will not be over-written.

Example:
```
$ cat existing
AAAAAAAA
$ cat existing
bbbAAAAA
```

I looked over the context that this function is used in and decided that
this behavior must not be intentional. Thus it should be safe
to convert this function to `write_new`.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py