From: Kefu Chai Date: Wed, 10 Feb 2021 07:47:31 +0000 (+0800) Subject: mgr/prometheus: escape special chars using r-string X-Git-Tag: v16.2.0~106^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=feb00569edc5e077a893285fc669d7d7905a8fc9;p=ceph.git mgr/prometheus: escape special chars using r-string so we don't need to worry about escaping the backslash anymore. Signed-off-by: Kefu Chai (cherry picked from commit 734dd75f35fb24d319ee1ddbff09da53dfac8c72) --- diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index adf69adcf0a7..6a38ed36ed9c 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -880,7 +880,7 @@ class Module(MgrModule): # '*' can be used to indicate all pools or namespaces pools_string = cast(str, self.get_localized_module_option('rbd_stats_pools')) pool_keys = [] - for x in re.split('[\s,]+', pools_string): + for x in re.split(r'[\s,]+', pools_string): if not x: continue @@ -969,7 +969,7 @@ class Module(MgrModule): {'type': 'pool_id', 'regex': pool_id_regex}, {'type': 'namespace', 'regex': namespace_regex}, {'type': 'object_name', - 'regex': '^(?:rbd|journal)_data\.(?:([0-9]+)\.)?([^.]+)\.'}, + 'regex': r'^(?:rbd|journal)_data\.(?:([0-9]+)\.)?([^.]+)\.'}, ], 'performance_counter_descriptors': list(counters_info), } @@ -1118,7 +1118,7 @@ class Module(MgrModule): new_metrics = {} for metric_path in self.metrics.keys(): # Address RGW sync perf. counters. - match = re.search('^data-sync-from-(.*)\.', metric_path) + match = re.search(r'^data-sync-from-(.*)\.', metric_path) if match: new_path = re.sub('from-([^.]*)', 'from-zone', metric_path) if new_path not in new_metrics: