cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #06634
[Merge] ~daniel-thewatkins/cloud-init/+git/cloud-init:lp1843276 into cloud-init:master
Dan Watkins has proposed merging ~daniel-thewatkins/cloud-init/+git/cloud-init:lp1843276 into cloud-init:master.
Commit message:
atomic_helper: add DEBUG logging to write_file
Fixes LP: #1843276
Requested reviews:
Server Team CI bot (server-team-bot): continuous-integration
cloud-init Commiters (cloud-init-dev)
Related bugs:
Bug #1843276 in cloud-init: "cloudinit.atomic_helper.write_file should have the same logging as util.write_file"
https://bugs.launchpad.net/cloud-init/+bug/1843276
For more details, see:
https://code.launchpad.net/~daniel-thewatkins/cloud-init/+git/cloud-init/+merge/372491
--
Your team cloud-init Commiters is requested to review the proposed merge of ~daniel-thewatkins/cloud-init/+git/cloud-init:lp1843276 into cloud-init:master.
diff --git a/cloudinit/atomic_helper.py b/cloudinit/atomic_helper.py
index 587b994..077a780 100644
--- a/cloudinit/atomic_helper.py
+++ b/cloudinit/atomic_helper.py
@@ -1,11 +1,13 @@
# This file is part of cloud-init. See LICENSE file for license information.
import json
+import logging
import os
import stat
import tempfile
_DEF_PERMS = 0o644
+LOG = logging.getLogger(__name__)
def write_file(filename, content, mode=_DEF_PERMS,
@@ -23,9 +25,12 @@ def write_file(filename, content, mode=_DEF_PERMS,
try:
tf = tempfile.NamedTemporaryFile(dir=os.path.dirname(filename),
delete=False, mode=omode)
+ LOG.debug("Writing to temporary file %s - %s: [%s] %s bytes/chars",
+ tf.name, omode, mode, len(content))
tf.write(content)
tf.close()
os.chmod(tf.name, mode)
+ LOG.debug("Renaming temporary file %s to %s", tf.name, filename)
os.rename(tf.name, filename)
except Exception as e:
if tf is not None:
Follow ups