From b9f0702f1d4023f91506eb9ef02ad0ed38aa9474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Vonheiden?= <bjoern.vonheiden@hotmail.de> Date: Sat, 26 Sep 2020 15:58:00 +0200 Subject: [PATCH] Use the streams api in run uc py to use the zookeeper-client --- execution/run_uc.py | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/execution/run_uc.py b/execution/run_uc.py index bb2c91919..3b46c50ac 100644 --- a/execution/run_uc.py +++ b/execution/run_uc.py @@ -370,22 +370,14 @@ def reset_zookeeper(): print('Delete ZooKeeper configurations used for workload generation') delete_zoo_data_command = [ - 'kubectl', - 'exec', - 'zookeeper-client', - '--', - 'bash', + '/bin/sh', '-c', 'zookeeper-shell my-confluent-cp-zookeeper:2181 deleteall ' + '/workload-generation' ] check_zoo_data_command = [ - 'kubectl', - 'exec', - 'zookeeper-client', - '--', - 'bash', + '/bin/sh', '-c', 'zookeeper-shell my-confluent-cp-zookeeper:2181 get ' + '/workload-generation' @@ -394,18 +386,25 @@ def reset_zookeeper(): # Wait for configuration deletion while True: # Delete Zookeeper configuration data - output = subprocess.run(delete_zoo_data_command, - capture_output=True, - text=True) - logging.debug(output.stdout) + resp = stream(coreApi.connect_get_namespaced_pod_exec, + "zookeeper-client", + 'default', + command=delete_zoo_data_command, + stderr=True, stdin=False, + stdout=True, tty=False) + logging.debug(resp) # Check data is deleted - output = subprocess.run(check_zoo_data_command, - capture_output=True, - text=True) - logging.debug(output) + client = stream(coreApi.connect_get_namespaced_pod_exec, + "zookeeper-client", + 'default', + command=check_zoo_data_command, + stderr=True, stdin=False, + stdout=True, tty=False, + _preload_content=False) # Get client for returncode + client.run_forever(timeout=60) # Start the client - if output.returncode == 1: # Means data not available anymore + if client.returncode == 1: # Means data not available anymore print('ZooKeeper reset was successful.') break else: -- GitLab