From 5ff6313aa7fc5c087ee8cd922e6c23b55d8b8213 Mon Sep 17 00:00:00 2001 From: Vijay Venkatesh Kumar Date: Wed, 19 Oct 2022 15:25:42 +0000 Subject: Handle MR connection error Change-Id: I8defdd65093d19d4255427a8c7961cf5249007b8 Signed-off-by: Vijay Venkatesh Kumar Issue-ID: DCAEGEN2-2952 Signed-off-by: Vijay Venkatesh Kumar (cherry picked from commit 462cee04e5d952f544a8300dc5a0d1e297482e3f) --- Changelog.md | 3 +++ miss_htbt_service/htbtworker.py | 11 ++++++++--- pom.xml | 2 +- setup.py | 2 +- version.properties | 4 ++-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index f58fc8c..4631560 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.5.0] - 2022/10/19 +- [DCAEGEN2-2952] Handle exception when MR is unavailable + ## [2.4.1] - 2022/09/23 - [DCAEGEN2-2837] Heartbeat ms: remove unnecessary parenthesis, use lowercase variable name - [DCAEGEN2-3268] Fix cryptography version to 37.0.4 diff --git a/miss_htbt_service/htbtworker.py b/miss_htbt_service/htbtworker.py index ac7a0d9..0d43533 100644 --- a/miss_htbt_service/htbtworker.py +++ b/miss_htbt_service/htbtworker.py @@ -98,9 +98,14 @@ def process_msg(jsfile, user_name, password, ip_address, port_num, db_name): i = 0 break else: - res = requests.get(get_url) - msg = "HBT:", res.text - _logger.info(msg) + try: + res = requests.get(get_url) + except Exception as e: + # message-router may be down temporarily. continue polling loop to try again + _logger.error('HBT: Failed to fetch messages from DMaaP. get_url=%s', get_url, exc_info=e) + time.sleep(1) + continue + _logger.info("HBT: %s", res.text) input_string = res.text # If mrstatus in message body indicates some information, not json msg. if "mrstatus" in input_string: diff --git a/pom.xml b/pom.xml index 2f6390e..fbf5c20 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ limitations under the License. org.onap.dcaegen2.services heartbeat dcaegen2-services-heartbeat - 2.4.1 + 2.5.0 UTF-8 . diff --git a/setup.py b/setup.py index 2fada3f..2104015 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ from setuptools import setup, find_packages setup( name="miss_htbt_service", description="Missing heartbeat microservice to communicate with policy-engine", - version="2.4.1", + version="2.5.0", # packages=find_packages(exclude=["tests.*", "tests"]), packages=find_packages(), install_requires=[ diff --git a/version.properties b/version.properties index a88b650..6c69733 100644 --- a/version.properties +++ b/version.properties @@ -1,6 +1,6 @@ major=2 -minor=4 -patch=1 +minor=5 +patch=0 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg