From 0e85f185b6a607647a13a0e670eb7038e9be32f8 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 5 Feb 2020 16:45:52 -0600 Subject: [PATCH] mgr/telemetry: use raise_for_status() Signed-off-by: Sage Weil --- src/pybind/mgr/telemetry/module.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index 2d3a5bb2406..2ef7ccfb9a7 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: -- 2.39.5