From b3e9ea1c3b23d17b2449838cce330a01c2b13019 Mon Sep 17 00:00:00 2001 From: NITESH SINGH Date: Wed, 1 Apr 2026 18:23:21 +0530 Subject: [PATCH] fix(utils): fix HealthChecker bool comparisons and add missing return value (#1216) - Replace '!= False' with 'is not False' and '== True' with 'is True' for idiomatic Python bool identity checks - Add missing 'return self.ret_value' so callers receive the exit code instead of always getting None - Add Apache 2.0 license header Signed-off-by: NETIZEN-11 Co-authored-by: Paige Patton <64206430+paigerube14@users.noreply.github.com> --- krkn/utils/HealthChecker.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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