mirror of
https://github.com/krkn-chaos/krkn.git
synced 2026-08-25 09:27:36 +00:00
Prioritize filtering on namespace to improve performance
This will avoid querying all namespaces for pods matching the label_selector if defined as shown in the sample scenario config. This commit also prints a pointer to the report generated at the end of the run.
This commit is contained in:
@@ -57,15 +57,28 @@ def skew_time(scenario):
|
||||
logging.error("Need to set namespace when using pod name")
|
||||
sys.exit(1)
|
||||
pod_names.append([name, scenario["namespace"]])
|
||||
elif "label_selector" in scenario.keys() and scenario["label_selector"]:
|
||||
pod_names = kubecli.get_all_pods(scenario["label_selector"])
|
||||
elif "namespace" in scenario.keys() and scenario["namespace"]:
|
||||
pod_names = kubecli.list_pods(scenario["namespace"])
|
||||
if "label_selector" not in scenario.keys():
|
||||
logging.info(
|
||||
"label_selector key not found, querying for all the pods in namespace: %s" % (scenario["namespace"])
|
||||
)
|
||||
pod_names = kubecli.list_pods(scenario["namespace"])
|
||||
else:
|
||||
logging.info(
|
||||
"Querying for the pods matching the %s label_selector in namespace %s"
|
||||
% (scenario["label_selector"], scenario["namespace"])
|
||||
)
|
||||
pod_names = kubecli.list_pods(scenario["namespace"], scenario["label_selector"])
|
||||
counter = 0
|
||||
for pod_name in pod_names:
|
||||
pod_names[counter] = [pod_name, scenario["namespace"]]
|
||||
counter += 1
|
||||
elif "label_selector" in scenario.keys() and scenario["label_selector"]:
|
||||
pod_names = kubecli.get_all_pods(scenario["label_selector"])
|
||||
|
||||
if len(pod_names) == 0:
|
||||
logging.info("Cannot find pods matching the namespace/label_selector, please check")
|
||||
sys.exit(1)
|
||||
for pod in pod_names:
|
||||
if len(pod) > 1:
|
||||
pod_exec(pod[0], skew_command, pod[1])
|
||||
|
||||
+5
-1
@@ -209,7 +209,11 @@ def main(cfg):
|
||||
logging.error("Post scenarios are still failing at the end of all iterations")
|
||||
sys.exit(1)
|
||||
|
||||
logging.info("Successfully finished running Kraken. UUID for the run: %s. Exiting" % (run_uuid))
|
||||
run_dir = os.getcwd() + "/kraken.report"
|
||||
logging.info(
|
||||
"Successfully finished running Kraken. UUID for the run: %s. Report generated at %s. Exiting"
|
||||
% (run_uuid, run_dir)
|
||||
)
|
||||
else:
|
||||
logging.error("Cannot find a config at %s, please check" % (cfg))
|
||||
sys.exit(1)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
time_scenarios:
|
||||
- action: skew_time
|
||||
object_type: pod
|
||||
label_selector: app=multus
|
||||
namespace: openshift-etcd
|
||||
label_selector: app=etcd
|
||||
- action: skew_date
|
||||
object_type: node
|
||||
label_selector: node-role.kubernetes.io/worker
|
||||
|
||||
Reference in New Issue
Block a user