Skip to content

Commit 7e9182c

Browse files
committed
adding few more cerberus check updates
1 parent efbe66f commit 7e9182c

File tree

4 files changed

+44
-50
lines changed

4 files changed

+44
-50
lines changed

krkn/cerberus/setup.py

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
check_application_routes = ""
88
cerberus_url = None
99
exit_on_failure = False
10+
cerberus_enabled = False
1011

1112
def set_url(config):
1213
global exit_on_failure
1314
exit_on_failure = get_yaml_item_value(config["kraken"], "exit_on_failure", False)
14-
if config["cerberus"]["cerberus_enabled"]:
15+
global cerberus_enabled
16+
cerberus_enabled = get_yaml_item_value(config["cerberus"],"cerberus_enabled", False)
17+
if cerberus_enabled:
1518
global cerberus_url
1619
cerberus_url = get_yaml_item_value(config["cerberus"],"cerberus_url", "")
1720
global check_application_routes
@@ -25,50 +28,50 @@ def get_status(start_time, end_time):
2528
cerberus_status = True
2629
check_application_routes = False
2730
application_routes_status = True
28-
29-
if not cerberus_url:
30-
logging.error(
31-
"url where Cerberus publishes True/False signal "
32-
"is not provided."
33-
)
34-
sys.exit(1)
35-
cerberus_status = requests.get(cerberus_url, timeout=60).content
36-
cerberus_status = True if cerberus_status == b"True" else False
31+
if cerberus_enabled:
32+
if not cerberus_url:
33+
logging.error(
34+
"url where Cerberus publishes True/False signal "
35+
"is not provided."
36+
)
37+
sys.exit(1)
38+
cerberus_status = requests.get(cerberus_url, timeout=60).content
39+
cerberus_status = True if cerberus_status == b"True" else False
3740

38-
# Fail if the application routes monitored by cerberus
39-
# experience downtime during the chaos
40-
if check_application_routes:
41-
application_routes_status, unavailable_routes = application_status(
42-
cerberus_url,
43-
start_time,
44-
end_time
45-
)
46-
if not application_routes_status:
41+
# Fail if the application routes monitored by cerberus
42+
# experience downtime during the chaos
43+
if check_application_routes:
44+
application_routes_status, unavailable_routes = application_status(
45+
cerberus_url,
46+
start_time,
47+
end_time
48+
)
49+
if not application_routes_status:
50+
logging.error(
51+
"Application routes: %s monitored by cerberus "
52+
"encountered downtime during the run, failing"
53+
% unavailable_routes
54+
)
55+
else:
56+
logging.info(
57+
"Application routes being monitored "
58+
"didn't encounter any downtime during the run!"
59+
)
60+
61+
if not cerberus_status:
4762
logging.error(
48-
"Application routes: %s monitored by cerberus "
49-
"encountered downtime during the run, failing"
50-
% unavailable_routes
63+
"Received a no-go signal from Cerberus, looks like "
64+
"the cluster is unhealthy. Please check the Cerberus "
65+
"report for more details. Test failed."
5166
)
67+
68+
if not application_routes_status or not cerberus_status:
69+
sys.exit(1)
5270
else:
5371
logging.info(
54-
"Application routes being monitored "
55-
"didn't encounter any downtime during the run!"
72+
"Received a go signal from Ceberus, the cluster is healthy. "
73+
"Test passed."
5674
)
57-
58-
if not cerberus_status:
59-
logging.error(
60-
"Received a no-go signal from Cerberus, looks like "
61-
"the cluster is unhealthy. Please check the Cerberus "
62-
"report for more details. Test failed."
63-
)
64-
65-
if not application_routes_status or not cerberus_status:
66-
sys.exit(1)
67-
else:
68-
logging.info(
69-
"Received a go signal from Ceberus, the cluster is healthy. "
70-
"Test passed."
71-
)
7275
return cerberus_status
7376

7477

krkn/scenario_plugins/abstract_scenario_plugin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,5 @@ def run_scenarios(
113113
cerberus.publish_kraken_status(start_time, end_time)
114114
logging.info(f"wating {wait_duration} before running the next scenario")
115115
time.sleep(wait_duration)
116-
117116

118117
return failed_scenarios, scenario_telemetries

krkn/scenario_plugins/native/plugins.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self, steps: List[PluginStep]):
5454
def unserialize_scenario(self, file: str) -> Any:
5555
return serialization.load_from_file(abspath(file))
5656

57-
def run(self, file: str, kubeconfig_path: str, kraken_config: str, run_uuid: str):
57+
def run(self, file: str, kubeconfig_path: str, run_uuid: str):
5858
"""
5959
Run executes a series of steps
6060
"""
@@ -98,8 +98,6 @@ def run(self, file: str, kubeconfig_path: str, kraken_config: str, run_uuid: str
9898
unserialized_input = step.schema.input.unserialize(entry["config"])
9999
if "kubeconfig_path" in step.schema.input.properties:
100100
unserialized_input.kubeconfig_path = kubeconfig_path
101-
if "kraken_config" in step.schema.input.properties:
102-
unserialized_input.kraken_config = kraken_config
103101
output_id, output_data = step.schema(
104102
params=unserialized_input, run_id=run_uuid
105103
)

krkn/scenario_plugins/pvc/pvc_scenario_plugin.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
from krkn_lib.k8s import KrknKubernetes
88
from krkn_lib.models.telemetry import ScenarioTelemetry
99
from krkn_lib.telemetry.ocp import KrknTelemetryOpenshift
10-
from krkn_lib.utils import get_yaml_item_value, log_exception
10+
from krkn_lib.utils import get_yaml_item_value
1111

12-
from krkn import cerberus, utils
1312
from krkn.scenario_plugins.abstract_scenario_plugin import AbstractScenarioPlugin
1413

1514

@@ -18,7 +17,6 @@ def run(
1817
self,
1918
run_uuid: str,
2019
scenario: str,
21-
krkn_config: dict[str, any],
2220
lib_telemetry: KrknTelemetryOpenshift,
2321
scenario_telemetry: ScenarioTelemetry,
2422
) -> int:
@@ -173,7 +171,6 @@ def run(
173171
)
174172
)
175173

176-
start_time = int(time.time())
177174
# Create temp file in the PVC
178175
full_path = "%s/%s" % (str(mount_path), str(file_name))
179176
command = "fallocate -l $((%s*1024)) %s" % (
@@ -233,7 +230,6 @@ def run(
233230
)
234231
)
235232

236-
start_time = int(time.time())
237233
# Create temp file in the PVC
238234
full_path = "%s/%s" % (str(mount_path), str(file_name))
239235
command = "fallocate -l $((%s*1024)) %s" % (
@@ -269,8 +265,6 @@ def run(
269265
file_size_kb,
270266
lib_telemetry.get_lib_kubernetes(),
271267
)
272-
end_time = int(time.time())
273-
cerberus.publish_kraken_status(krkn_config, [], start_time, end_time)
274268
except (RuntimeError, Exception) as e:
275269
logging.error("PvcScenarioPlugin exiting due to Exception %s" % e)
276270
return 1

0 commit comments

Comments
 (0)