From b338ffa03803b815a3fc55c2ca80bed84fc12678 Mon Sep 17 00:00:00 2001 From: Yaarit Hatuka Date: Sun, 5 Jan 2020 22:16:56 -0500 Subject: [PATCH] mgr/telemetry: fix device serial number anonymization MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - Model names sometimes have underscores in them, hence it is not safe to split the string __ by '_' and expect the correct corresponding tuple. For now we'll take the string after the last '_' as the serial. - Fixed back_ip to be retrieved from cluster_addrs instead of public_addrs. - Omitted the ':' from 'pg_num:' key. This won't break the telemetry server since it does not extract this key, but calculates it from 'pools'. Signed-off-by: Yaarit Hatuka (cherry picked from commit e4d5ece05ec76aea7392ee4e41a34082692f0df6) Conflicts: ceph-mgr in nautilus is still using python2, we should use python2 compatible syntax in this backport commit. See https://github.com/ceph/ceph/pull/32926 --- src/pybind/mgr/telemetry/module.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index 3844229031032..9c639ff7e833c 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -386,10 +386,9 @@ class Module(MgrModule): rep['host_id'] = anon_host # anonymize device id - (vendor, model, serial) = devid.split('_') anon_devid = self.get_store('devid-id/%s' % devid) if not anon_devid: - anon_devid = '%s_%s_%s' % (vendor, model, uuid.uuid1()) + anon_devid = devid[:devid.rfind('_')] + '_' + uuid.uuid1() self.set_store('devid-id/%s' % devid, anon_devid) self.log.info('devid %s / %s, host %s / %s' % (devid, anon_devid, host, anon_host)) @@ -515,7 +514,7 @@ class Module(MgrModule): for osd in osd_map['osds']: if osd['up'] and not cluster_network: front_ip = osd['public_addrs']['addrvec'][0]['addr'].split(':')[0] - back_ip = osd['public_addrs']['addrvec'][0]['addr'].split(':')[0] + back_ip = osd['cluster_addrs']['addrvec'][0]['addr'].split(':')[0] if front_ip != back_ip: cluster_network = True report['osd'] = { @@ -609,7 +608,7 @@ class Module(MgrModule): report['usage'] = { 'pools': len(df['pools']), - 'pg_num:': num_pg, + 'pg_num': num_pg, 'total_used_bytes': df['stats']['total_used_bytes'], 'total_bytes': df['stats']['total_bytes'], 'total_avail_bytes': df['stats']['total_avail_bytes'] -- 2.39.5