From cbe600eaa80a2a0b99704ff868fd6eab33070397 Mon Sep 17 00:00:00 2001 From: Yaarit Hatuka Date: Thu, 5 Mar 2020 09:42:46 -0500 Subject: [PATCH] mgr/telemetry: force --license when sending while opted-out MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Users can manually send telemetry data with 'ceph telemetry send', even in case they did not opt-in and agree to the license. We ask to explicitly add '--license' to 'ceph telemetry send' in this case. This also fixes an issue when opting-out ('ceph telemetry off'), where the revision was not reset. Fixes: https://tracker.ceph.com/issues/44442 Signed-off-by: Yaarit Hatuka --- src/pybind/mgr/telemetry/module.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index d1f416c69f908..4fbfe8f7c03e4 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -159,7 +159,8 @@ class Module(MgrModule): }, { "cmd": "telemetry send " - "name=endpoint,type=CephChoices,strings=ceph|device,n=N,req=false", + "name=endpoint,type=CephChoices,strings=ceph|device,n=N,req=false " + "name=license,type=CephString,req=false", "desc": "Force sending data to Ceph telemetry", "perm": "rw" }, @@ -744,9 +745,12 @@ class Module(MgrModule): return 0, '', '' elif command['prefix'] == 'telemetry off': self.set_module_option('enabled', False) - self.set_module_option('last_opt_revision', REVISION) + self.set_module_option('last_opt_revision', 1) return 0, '', '' elif command['prefix'] == 'telemetry send': + if self.last_opt_revision < LAST_REVISION_RE_OPT_IN and command.get('license') != LICENSE: + self.log.debug('A telemetry send attempt while opted-out. Asking for license agreement') + return -errno.EPERM, '', "Telemetry data is licensed under the " + LICENSE_NAME + " (" + LICENSE_URL + ").\nTo manually send telemetry data, add '--license " + LICENSE + "' to the 'ceph telemetry send' command.\nPlease consider enabling the telemetry module with 'ceph telemetry on'." self.last_report = self.compile_report() return self.send(self.last_report, command.get('endpoint')) -- 2.39.5