From: Sage Weil Date: Wed, 5 Feb 2020 22:45:52 +0000 (-0600) Subject: mgr/telemetry: use raise_for_status() X-Git-Tag: v14.2.10~166^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4200b3d873f6ca0c8c9bb79e9f292c056366fcc5;p=ceph.git mgr/telemetry: use raise_for_status() Signed-off-by: Sage Weil (cherry picked from commit 0e85f185b6a607647a13a0e670eb7038e9be32f8) --- diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index b3047d337d0..7473b6bb29d 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -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: