Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gu <[email protected]>
  • Loading branch information
tylergu committed Nov 15, 2023
1 parent 7e27f3d commit dfaffdd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions acto/runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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'][
Expand All @@ -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
Expand Down

0 comments on commit dfaffdd

Please sign in to comment.