Skip to content

Commit

Permalink
fix(node): cleanup node exec in test case teardown
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Chiu <[email protected]>
  • Loading branch information
yangchiu committed Nov 7, 2024
1 parent 0599e6d commit 3c32edb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions e2e/keywords/common.resource
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Cleanup test resources
uncordon_all_nodes
cleanup_control_plane_network_latency
reset_node_schedule
cleanup_node_exec
cleanup_stress_helper
cleanup_recurringjobs
cleanup_deployments
Expand Down
5 changes: 5 additions & 0 deletions e2e/libs/keywords/common_keywords.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from node import Node
from node_exec import NodeExec
from utility.utility import init_k8s_api_client
from utility.utility import generate_name_with_suffix

Expand All @@ -19,3 +20,7 @@ def get_worker_nodes(self):

def get_node_by_index(self, node_id):
return Node().get_node_by_index(node_id)

def cleanup_node_exec(self):
for node_name in Node().list_node_names_by_role("all"):
NodeExec(node_name).cleanup()
6 changes: 4 additions & 2 deletions e2e/libs/node_exec/node_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ class NodeExec:
def __init__(self, node_name):
self.node_name = node_name
self.core_api = client.CoreV1Api()
self.cleanup()
self.pod = self.launch_pod()

def cleanup(self):
if get_pod(self.node_name):
logging(f"Cleaning up pod {self.node_name}")
delete_pod(self.node_name)

def issue_cmd(self, cmd):

self.cleanup()
self.pod = self.launch_pod()

logging(f"Issuing command on {self.node_name}: {cmd}")

if isinstance(cmd, list):
Expand Down

0 comments on commit 3c32edb

Please sign in to comment.