]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: check for errors when sending report
authorDan Mick <dan.mick@redhat.com>
Sat, 16 Mar 2019 03:05:46 +0000 (20:05 -0700)
committerJoao Eduardo Luis <joao@suse.com>
Mon, 9 Dec 2019 19:36:54 +0000 (19:36 +0000)
There was no error checking, and the server has been failing for
some time, but no one noticed.  Oops.

Signed-off-by: Dan Mick <dan.mick@redhat.com>
(cherry picked from commit de71f38a2c0b37a96970d6b2fd62ea19b20bdf46)

Conflicts:
src/pybind/mgr/telemetry/module.py
          mostly due to store_get/store_set not existing in luminous,
          and we relying instead on config_get/config_set.

src/pybind/mgr/telemetry/module.py

index fe1203411cf698f9c55c84f6f5d0f47093b84589..cde9c20b1df507ecd1a96bc68352e75e2eeb7959 100644 (file)
@@ -294,7 +294,12 @@ class Module(MgrModule):
             proxies['http'] = self.config['proxy']
             proxies['https'] = self.config['proxy']
 
-        requests.put(url=self.config['url'], json=report, proxies=proxies)
+        resp = requests.put(url=self.config['url'],
+                            json=report, proxies=proxies)
+        if not resp.ok:
+            self.log.error("Report send failed: %d %s %s" %
+                           (resp.status_code, resp.reason, resp.text))
+        return resp
 
     def handle_command(self, command):
         if command['prefix'] == 'telemetry config-show':
@@ -317,8 +322,15 @@ class Module(MgrModule):
             return 0, '', ''
         elif command['prefix'] == 'telemetry send':
             self.last_report = self.compile_report()
-            self.send(self.last_report)
-            return 0, 'Report send to {0}'.format(self.config['url']), ''
+            resp = self.send(self.last_report)
+            if resp.ok:
+                return 0, 'Report sent to {0}'.format(self.config['url']), ''
+            return 1, '', 'Failed to send report to %s: %d %s %s' % (
+                self.config['url'],
+                resp.status_code,
+                resp.reason,
+                resp.text
+            )
         elif command['prefix'] == 'telemetry show':
             report = self.last_report
             if not report:
@@ -368,9 +380,12 @@ class Module(MgrModule):
                     self.log.exception('Exception while compiling report:')
 
                 try:
-                    self.send(self.last_report)
-                    self.last_upload = now
-                    self.set_config('last_upload', str(now))
+                    resp = self.send(self.last_report)
+                    # self.send logs on failure; only update last_upload
+                    # if we succeed
+                    if resp.ok:
+                        self.last_upload = now
+                        self.set_config('last_upload', str(now))
                 except:
                     self.log.exception('Exception while sending report:')
             else: