]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/influx: avoid casting variable
authorKefu Chai <kchai@redhat.com>
Mon, 22 Feb 2021 06:03:44 +0000 (14:03 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 25 Feb 2021 07:54:12 +0000 (15:54 +0800)
self.config is a dict with elements of different types, to appease mypy,
we would need to cast the indexed item to the expected type. another way
is to use f-string, so the variable are always printed using `__str__`.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/influx/module.py

index c58d2d547d8365bcb0ce742d34db375fd092144b..4d2c46c343c7b93addce353885506957e24710ba 100644 (file)
@@ -122,15 +122,14 @@ class Module(MgrModule):
                 self.log.debug('Writing points %d to Influx took %.3f seconds',
                                len(points), runtime)
             except RequestException as e:
-                self.log.exception("Failed to connect to Influx host %s:%d",
-                                   self.config['hostname'], self.config['port'])
+                hostname = self.config['hostname']
+                port = self.config['port']
+                self.log.exception(f"Failed to connect to Influx host {hostname}:{port}")
                 self.health_checks.update({
                     'MGR_INFLUX_SEND_FAILED': {
                         'severity': 'warning',
                         'summary': 'Failed to send data to InfluxDB server '
-                                   'at %s:%d due to an connection error'
-                                   % (self.config['hostname'],
-                                      self.config['port']),
+                                   f'at {hostname}:{port} due to an connection error',
                         'detail': [str(e)]
                     }
                 })