Skip to content
Snippets Groups Projects
Commit e4a26bc8 authored by Björn Vonheiden's avatar Björn Vonheiden
Browse files

integrate the atexit method in run uc py

parent dccb6aec
No related branches found
No related tags found
2 merge requests!42Integerate theodolite and run uc python scripts,!24run UC as python implementation
import argparse # parse arguments from cli
import atexit # used to clear resources at exit of program (e.g. ctrl-c)
from kubernetes import client, config # kubernetes api
from kubernetes.stream import stream
import logging # logging
......@@ -483,6 +484,7 @@ def reset_cluster(wg, app_svc, app_svc_monitor, app_jmx, app_deploy, topics):
"""
Stop the applications, delete topics, reset zookeeper and stop lag exporter.
"""
print('Reset cluster')
stop_applications(wg, app_svc, app_svc_monitor, app_jmx, app_deploy)
print('---------------------')
delete_topics(topics)
......@@ -491,7 +493,6 @@ def reset_cluster(wg, app_svc, app_svc_monitor, app_jmx, app_deploy, topics):
print('---------------------')
stop_lag_exporter()
def main():
load_variables()
print('---------------------')
......@@ -507,15 +508,20 @@ def main():
('aggregation-feedback', args.partitions),
('configuration', 1)]
# Check for reset options
if args.reset_only:
print('Reset only cluster')
# Only reset cluster an then end program
reset_cluster(wg, app_svc, app_svc_monitor, app_jmx, app_deploy, topics)
sys.exit()
if args.reset:
print('Reset cluster before execution')
# Reset cluster before execution
print('Reset only mode')
reset_cluster(wg, app_svc, app_svc_monitor, app_jmx, app_deploy, topics)
print('---------------------')
# Register the reset operation so that is executed at the end of program
atexit.register(reset_cluster, wg, app_svc, app_svc_monitor, app_jmx, app_deploy, topics)
create_topics(topics)
print('---------------------')
......@@ -532,7 +538,8 @@ def main():
wait_execution()
print('---------------------')
reset_cluster(wg, app_svc, app_svc_monitor, app_jmx, app_deploy, topics)
# Cluster is resetted with atexit method
# reset_cluster(wg, app_svc, app_svc_monitor, app_jmx, app_deploy, topics)
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment