diff --git a/krkn/utils/HealthChecker.py b/krkn/utils/HealthChecker.py index a6ab853d..c095db08 100644 --- a/krkn/utils/HealthChecker.py +++ b/krkn/utils/HealthChecker.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python +# # Copyright 2025 The Krkn Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,6 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import requests import time import logging @@ -62,9 +65,11 @@ class HealthChecker: "status_code": response["status_code"], "start_timestamp": start_timestamp } - if response["status_code"] != 200: - if response_tracker[config["url"]] != False: response_tracker[config["url"]] = False - if config["exit_on_failure"] and config["exit_on_failure"] == True and self.ret_value==0: self.ret_value = 2 + if response["status_code"] != 200: + if response_tracker[config["url"]] is not False: + response_tracker[config["url"]] = False + if config["exit_on_failure"] is True and self.ret_value == 0: + self.ret_value = 2 else: if response["status_code"] != health_check_tracker[config["url"]]["status_code"]: end_timestamp = datetime.now() @@ -99,4 +104,5 @@ class HealthChecker: health_check_telemetry_queue.put(health_check_telemetry) else: - logging.info("health checks config is not defined, skipping them") \ No newline at end of file + logging.info("health checks config is not defined, skipping them") + return self.ret_value