summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2019-03-16 21:47:29 +0100
committerSage Weil <sage@redhat.com>2019-03-16 21:47:29 +0100
commit5d1f6044d9e0b416d40c3dc926538f5f621df3b6 (patch)
tree5bd1e0c629c298b10814814311c484173f2a02e4
parentMerge PR #27000 into nautilus (diff)
parentmgr/telemetry: check for errors when sending report (diff)
downloadceph-5d1f6044d9e0b416d40c3dc926538f5f621df3b6.tar.xz
ceph-5d1f6044d9e0b416d40c3dc926538f5f621df3b6.zip
Merge PR #27002 into nautilus
* refs/pull/27002/head: mgr/telemetry: check for errors when sending report Reviewed-by: Sage Weil <sage@redhat.com>
-rw-r--r--src/pybind/mgr/telemetry/module.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py
index bdb4c6382be..99313a9c01f 100644
--- a/src/pybind/mgr/telemetry/module.py
+++ b/src/pybind/mgr/telemetry/module.py
@@ -263,7 +263,11 @@ class Module(MgrModule):
proxies['http'] = self.proxy
proxies['https'] = self.proxy
- requests.put(url=self.url, json=report, proxies=proxies)
+ resp = requests.put(url=self.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, inbuf, command):
if command['prefix'] == 'telemetry status':
@@ -279,8 +283,16 @@ 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.url), ''
+ resp = self.send(self.last_report)
+ if resp.ok:
+ return 0, 'Report sent to {0}'.format(self.url), ''
+ return 1, '', 'Failed to send report to %s: %d %s %s' % (
+ self.url,
+ resp.status_code,
+ resp.reason,
+ resp.text
+ )
+
elif command['prefix'] == 'telemetry show':
report = self.last_report
if not report:
@@ -328,9 +340,12 @@ class Module(MgrModule):
self.log.exception('Exception while compiling report:')
try:
- self.send(self.last_report)
- self.last_upload = now
- self.set_store('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_store('last_upload', str(now))
except:
self.log.exception('Exception while sending report:')
else: