Skip to content

Commit c583da1

Browse files
committed
adding few more cerberus check updates
1 parent b58d184 commit c583da1

File tree

5 files changed

+44
-55
lines changed

5 files changed

+44
-55
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
@@ -117,6 +117,5 @@ def run_scenarios(
117117
cerberus.publish_kraken_status(start_time, end_time)
118118
logging.info(f"wating {wait_duration} before running the next scenario")
119119
time.sleep(wait_duration)
120-
121120

122121
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
@@ -50,7 +50,7 @@ def __init__(self, steps: List[PluginStep]):
5050
def unserialize_scenario(self, file: str) -> Any:
5151
return serialization.load_from_file(abspath(file))
5252

53-
def run(self, file: str, kubeconfig_path: str, kraken_config: str, run_uuid: str):
53+
def run(self, file: str, kubeconfig_path: str, run_uuid: str):
5454
"""
5555
Run executes a series of steps
5656
"""
@@ -94,8 +94,6 @@ def run(self, file: str, kubeconfig_path: str, kraken_config: str, run_uuid: str
9494
unserialized_input = step.schema.input.unserialize(entry["config"])
9595
if "kubeconfig_path" in step.schema.input.properties:
9696
unserialized_input.kubeconfig_path = kubeconfig_path
97-
if "kraken_config" in step.schema.input.properties:
98-
unserialized_input.kraken_config = kraken_config
9997
output_id, output_data = step.schema(
10098
params=unserialized_input, run_id=run_uuid
10199
)

krkn/scenario_plugins/pvc/pvc_scenario_plugin.py

Lines changed: 1 addition & 6 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:
@@ -176,7 +174,6 @@ def run(
176174
)
177175
)
178176

179-
start_time = int(time.time())
180177
# Create temp file in the PVC
181178
full_path = "%s/%s" % (str(mount_path), str(file_name))
182179

@@ -262,8 +259,6 @@ def run(
262259
file_size_kb,
263260
lib_telemetry.get_lib_kubernetes(),
264261
)
265-
end_time = int(time.time())
266-
cerberus.publish_kraken_status(krkn_config, [], start_time, end_time)
267262
except (RuntimeError, Exception) as e:
268263
logging.error("PvcScenarioPlugin exiting due to Exception %s" % e)
269264
return 1

krkn/scenario_plugins/zone_outage/zone_outage_scenario_plugin.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@
1111
from krkn_lib.models.telemetry import ScenarioTelemetry
1212
from krkn_lib.telemetry.ocp import KrknTelemetryOpenshift
1313

14-
<<<<<<< HEAD
15-
from krkn_lib.utils import get_yaml_item_value
16-
from krkn.scenario_plugins.abstract_scenario_plugin import AbstractScenarioPlugin
17-
from krkn.scenario_plugins.native.network import cerberus
18-
=======
1914
from krkn.scenario_plugins.abstract_scenario_plugin import AbstractScenarioPlugin
2015
from krkn.scenario_plugins.node_actions.aws_node_scenarios import AWS
21-
>>>>>>> 3f2b248 (cerbuerus chagnes)
2216

2317
from krkn.scenario_plugins.node_actions.aws_node_scenarios import AWS
2418
from krkn.scenario_plugins.node_actions.gcp_node_scenarios import gcp_node_scenarios

0 commit comments

Comments
 (0)