]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: write config files as utf-8
authorSage Weil <sage@newdream.net>
Tue, 18 May 2021 12:23:36 +0000 (08:23 -0400)
committerPatrick Seidensal <pseidensal@suse.com>
Mon, 28 Jun 2021 18:36:33 +0000 (20:36 +0200)
If we don't specify the encoding, python may use something like 'latin-1',
which cannot handle unicode characters.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit fa2cf2987cccea9f152c04862fc684e146c4692e)

Conflicts:
    src/cephadm/cephadm

src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 662b758d4127cf195101792e01bcca20c3f33a12..a8ee463bb17b5645a8133111cd0ce9014f921800 100755 (executable)
@@ -1854,7 +1854,7 @@ def create_daemon_dirs(fsid, daemon_type, daemon_id, uid, gid,
                     fpath = os.path.join(data_dir_root, fname.lstrip(os.path.sep))
                 else:
                     fpath = os.path.join(data_dir_root, config_dir, fname)
-                with open(fpath, 'w') as f:
+                with open(fpath, 'w', encoding='utf-8') as f:
                     os.fchown(f.fileno(), uid, gid)
                     os.fchmod(f.fileno(), 0o600)
                     f.write(content)
index e5787fe50062a657096b9d70905e8f1cfa5c3372..66b3ca7b39dfe1670b5b1a42d9c0e2c7a7a03170 100644 (file)
@@ -550,8 +550,10 @@ class TestMonitoring(object):
             daemon_id=daemon_id
         )
         assert _open.call_args_list == [
-            call('{}/etc/prometheus/prometheus.yml'.format(prefix), 'w'),
-            call('{}/etc/prometheus/alerting/ceph_alerts.yml'.format(prefix), 'w'),
+            call('{}/etc/prometheus/prometheus.yml'.format(prefix), 'w',
+                 encoding='utf-8'),
+            call('{}/etc/prometheus/alerting/ceph_alerts.yml'.format(prefix), 'w',
+                 encoding='utf-8'),
         ]
         assert call().__enter__().write('foo') in _open.mock_calls
         assert call().__enter__().write('bar') in _open.mock_calls