Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

clean any prior runs from the same CI namespace before starting. #392

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions rl_coach/tests/test_eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,24 @@ def get_return_status(self):
if container_status.state.terminated is not None:
return container_status.state.terminated.exit_code

def cleanup(self):
def cleanup(self, silent=False):

# Delete pod
try:
self.corev1_api.delete_namespaced_pod(self.test_name, self.namespace, client.V1DeleteOptions())
self.corev1_api.delete_namespaced_pod(self.test_name,
self.namespace,
client.V1DeleteOptions(grace_period_seconds=0))
except client.rest.ApiException as e:
print("Got exception while deleting pod: {}".format(e))
if not silent:
print("Got exception while deleting pod: {}".format(e))

# Delete namespace
try:
self.corev1_api.delete_namespace(self.namespace, client.V1DeleteOptions())
self.corev1_api.delete_namespace(self.namespace,
client.V1DeleteOptions(grace_period_seconds=0))
except client.rest.ApiException as e:
print("Got exception while deleting namespace: {}".format(e))
if not silent:
print("Got exception while deleting namespace: {}".format(e))


if __name__ == '__main__':
Expand Down Expand Up @@ -181,6 +186,10 @@ def cleanup(self):
args.image, args.cpu, args.mem, args.working_dir
)

# circleCI outages can cause a job to automatically be re-run (same namespace, test name).
# Ensure any prior runs are cleaned up before starting this run.
obj.cleanup(silent=True)

if obj.deploy() != 0:
obj.cleanup()
pytest.fail("Failed to deploy")
Expand Down