diff --git a/krkn/scenario_plugins/container/container_scenario_plugin.py b/krkn/scenario_plugins/container/container_scenario_plugin.py index 513ea300..1c8e6ec2 100644 --- a/krkn/scenario_plugins/container/container_scenario_plugin.py +++ b/krkn/scenario_plugins/container/container_scenario_plugin.py @@ -70,6 +70,7 @@ class ContainerScenarioPlugin(AbstractScenarioPlugin): container_name = get_yaml_item_value(cont_scenario, "container_name", "") kill_action = get_yaml_item_value(cont_scenario, "action", 1) kill_count = get_yaml_item_value(cont_scenario, "count", 1) + exclude_label = get_yaml_item_value(cont_scenario, "exclude_label", "") if not isinstance(kill_action, int): logging.error( "Please make sure the action parameter defined in the " @@ -91,7 +92,19 @@ class ContainerScenarioPlugin(AbstractScenarioPlugin): pods = kubecli.get_all_pods(label_selector) else: # Only returns pod names - pods = kubecli.list_pods(namespace, label_selector) + # Use list_pods with exclude_label parameter to exclude pods + if exclude_label: + logging.info( + "Using exclude_label '%s' to exclude pods from container scenario %s in namespace %s", + exclude_label, + scenario_name, + namespace, + ) + pods = kubecli.list_pods( + namespace=namespace, + label_selector=label_selector, + exclude_label=exclude_label if exclude_label else None + ) else: if namespace == "*": logging.error( @@ -102,6 +115,7 @@ class ContainerScenarioPlugin(AbstractScenarioPlugin): # sys.exit(1) raise RuntimeError() pods = pod_names + # get container and pod name container_pod_list = [] for pod in pods: diff --git a/scenarios/kube/container_dns.yml b/scenarios/kube/container_dns.yml index 3392bdc2..391e52b5 100755 --- a/scenarios/kube/container_dns.yml +++ b/scenarios/kube/container_dns.yml @@ -6,3 +6,4 @@ scenarios: action: 1 count: 1 retry_wait: 60 + exclude_label: "" diff --git a/scenarios/openshift/container_etcd.yml b/scenarios/openshift/container_etcd.yml index 4f4d5f4f..503d7849 100755 --- a/scenarios/openshift/container_etcd.yml +++ b/scenarios/openshift/container_etcd.yml @@ -6,3 +6,4 @@ scenarios: action: 1 count: 1 expected_recovery_time: 120 + exclude_label: "" \ No newline at end of file