add connection error catch when connecting prometheus
(cherry picked from commit e45aa8ab578a32ed65966ce1cab4e1850a844ecc)
This commit is contained in:
parent
b28ea577a5
commit
66b0128112
41
0002-add-error-catch-when-connect-pro.patch
Normal file
41
0002-add-error-catch-when-connect-pro.patch
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
From dfd2f38fd34d300448ed9231377fcf4a0be7d367 Mon Sep 17 00:00:00 2001
|
||||||
|
From: zhu-yuncheng <zhuyuncheng@huawei.com>
|
||||||
|
Date: Sat, 23 Dec 2023 17:43:18 +0800
|
||||||
|
Subject: [PATCH] add httpconnection error catch when connect prometheus
|
||||||
|
|
||||||
|
---
|
||||||
|
vulcanus/database/proxy.py | 10 +++++++---
|
||||||
|
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/vulcanus/database/proxy.py b/vulcanus/database/proxy.py
|
||||||
|
index 94e9883..5753066 100644
|
||||||
|
--- a/vulcanus/database/proxy.py
|
||||||
|
+++ b/vulcanus/database/proxy.py
|
||||||
|
@@ -16,9 +16,9 @@ Author:
|
||||||
|
Description: Database proxy
|
||||||
|
"""
|
||||||
|
from functools import wraps
|
||||||
|
-import math
|
||||||
|
from datetime import datetime
|
||||||
|
from urllib3.exceptions import LocationValueError
|
||||||
|
+from requests.exceptions import ConnectionError
|
||||||
|
|
||||||
|
import sqlalchemy
|
||||||
|
from sqlalchemy.exc import SQLAlchemyError, DisconnectionError
|
||||||
|
@@ -543,8 +543,12 @@ class PromDbProxy(DataBaseProxy):
|
||||||
|
Returns:
|
||||||
|
bool: connect succeed or fail
|
||||||
|
"""
|
||||||
|
-
|
||||||
|
- return self._prom.check_prometheus_connection()
|
||||||
|
+ connected = False
|
||||||
|
+ try:
|
||||||
|
+ connected = self._prom.check_prometheus_connection()
|
||||||
|
+ except ConnectionError as error:
|
||||||
|
+ LOGGER.error(error)
|
||||||
|
+ return connected
|
||||||
|
|
||||||
|
def query(self, host, time_range, metric, label_config=None):
|
||||||
|
"""
|
||||||
|
--
|
||||||
|
Gitee
|
||||||
@ -1,12 +1,12 @@
|
|||||||
Name: aops-vulcanus
|
Name: aops-vulcanus
|
||||||
Version: v1.3.1
|
Version: v1.3.1
|
||||||
Release: 2
|
Release: 3
|
||||||
Summary: A basic tool libraries of aops, including logging, configure and response, etc.
|
Summary: A basic tool libraries of aops, including logging, configure and response, etc.
|
||||||
License: MulanPSL2
|
License: MulanPSL2
|
||||||
URL: https://gitee.com/openeuler/%{name}
|
URL: https://gitee.com/openeuler/%{name}
|
||||||
Source0: %{name}-%{version}.tar.gz
|
Source0: %{name}-%{version}.tar.gz
|
||||||
Patch0001: 0001-update-ValidateRules.patch
|
Patch0001: 0001-update-ValidateRules.patch
|
||||||
|
Patch0002: 0002-add-error-catch-when-connect-pro.patch
|
||||||
|
|
||||||
|
|
||||||
BuildRequires: python3-setuptools
|
BuildRequires: python3-setuptools
|
||||||
@ -62,6 +62,9 @@ cp -r scripts %{buildroot}/opt/aops/
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Dec 23 2023 zhuyuncheng<zhuyuncheng@huawei.com> - v1.3.1-3
|
||||||
|
- add Http connection error catch when connecting to prometheus
|
||||||
|
|
||||||
* Thu Dec 21 2023 wenxin<wenxin32@foxmail.com> - v1.3.1-2
|
* Thu Dec 21 2023 wenxin<wenxin32@foxmail.com> - v1.3.1-2
|
||||||
- add IPV4 validation method to ValidateRules
|
- add IPV4 validation method to ValidateRules
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user