]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: force --license when sending while opted-out
authorYaarit Hatuka <yaarit@redhat.com>
Thu, 5 Mar 2020 14:42:46 +0000 (09:42 -0500)
committerYaarit Hatuka <yaarit@redhat.com>
Thu, 5 Mar 2020 14:42:46 +0000 (09:42 -0500)
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 <yaarit@redhat.com>
src/pybind/mgr/telemetry/module.py

index d1f416c69f90816538255ffb5d5426403be1bb8b..4fbfe8f7c03e4e4e814d8cdac6e0598392211747 100644 (file)
@@ -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'))