diff --git a/acto/runner/runner.py b/acto/runner/runner.py index 181baa537e..fbd911bb8f 100644 --- a/acto/runner/runner.py +++ b/acto/runner/runner.py @@ -206,7 +206,8 @@ def collect_system_state(self) -> dict: if resource == 'pod': # put pods managed by deployment / replicasets into an array all_pods = self.__get_all_objects(method) - resources['deployment_pods'], resources['pod'] = group_pods(all_pods) + resources['deployment_pods'], resources['daemonset_pods'], resources['pod'] = group_pods( + all_pods) elif resource == 'secret': resources[resource] = decode_secret_data(resources[resource]) @@ -465,15 +466,16 @@ def decode_secret_data(secrets: dict) -> dict: return secrets -def group_pods(all_pods: dict) -> Tuple[dict, dict]: - '''Groups pods into deployment pods and other pods +def group_pods(all_pods: dict) -> Tuple[dict, dict, dict]: + '''Groups pods into deployment pods, daemonset pods, and other pods For deployment pods, they are further grouped by their owner reference Return: - Tuple of (deployment_pods, other_pods) + Tuple of (deployment_pods, daemonset_pods, other_pods) ''' deployment_pods = {} + daemonset_pods = {} other_pods = {} for name, pod in all_pods.items(): if 'acto/tag' in pod['metadata']['labels'] and pod['metadata']['labels'][ @@ -491,12 +493,18 @@ def group_pods(all_pods: dict) -> Tuple[dict, dict]: deployment_pods[owner_name] = [pod] else: deployment_pods[owner_name].append(pod) + elif owner_reference['kind'] == 'DaemonSet': + owner_name = owner_reference['name'] + if owner_name not in daemonset_pods: + daemonset_pods[owner_name] = [pod] + else: + daemonset_pods[owner_name].append(pod) else: other_pods[name] = pod else: other_pods[name] = pod - return deployment_pods, other_pods + return deployment_pods, daemonset_pods, other_pods # standalone runner for acto