mirror of
https://github.com/krkn-chaos/krkn.git
synced 2026-08-25 09:27:36 +00:00
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 <niteshkumar121411@gmail.com> Co-authored-by: Paige Patton <64206430+paigerube14@users.noreply.github.com>
This commit is contained in:
co-authored by
Paige Patton
parent
9f417d8f1a
commit
b3e9ea1c3b
@@ -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")
|
||||
logging.info("health checks config is not defined, skipping them")
|
||||
return self.ret_value
|
||||
|
||||
Reference in New Issue
Block a user