]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: use raise_for_status() 33141/head
authorSage Weil <sage@redhat.com>
Wed, 5 Feb 2020 22:45:52 +0000 (16:45 -0600)
committerShyukri Shyukriev <shshyukriev@suse.com>
Sat, 8 Feb 2020 20:52:16 +0000 (22:52 +0200)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 0e85f185b6a607647a13a0e670eb7038e9be32f8)

src/pybind/mgr/telemetry/module.py

index b3047d337d01a85911263ee16dbdb9b93eb4596d..7473b6bb29d6c81b806a6912fe9ee663a2b9b9b6 100644 (file)
@@ -671,23 +671,14 @@ class Module(MgrModule):
             self.log.info('Send using HTTP(S) proxy: %s', self.proxy)
             proxies['http'] = self.proxy
             proxies['https'] = self.proxy
-        fail_reason = None
         try:
             resp = requests.put(url=url, json=report)
-            if not resp.ok:
-                fail_reason = 'Failed to send %s to %s: %d %s %s' % (
-                    what,
-                    url,
-                    resp.status_code,
-                    resp.reason,
-                    resp.text
-                )
+            resp.raise_for_status()
         except Exception as e:
-            fail_reason = 'Failed to send %s to %s: %s' % (
-                what, url, str(e)))
-        if fail_reason:
+            fail_reason = 'Failed to send %s to %s: %s' % (what, url, str(e))
             self.log.error(fail_reason)
-        return fail_reason
+            return fail_reason
+        return None
 
     def send(self, report, endpoint=None):
         if not endpoint: