From: Sage Weil Date: Wed, 5 Feb 2020 22:45:52 +0000 (-0600) Subject: mgr/telemetry: use raise_for_status() X-Git-Tag: v15.1.1~508^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33070%2Fhead;p=ceph.git mgr/telemetry: use raise_for_status() Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index 2d3a5bb2406b9..2ef7ccfb9a793 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -666,23 +666,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: