@@ -2047,12 +2047,12 @@ def _replace(self, path, what, to):
20472047 def restart_instance_with_ip_change (self , node , new_ip ):
20482048 if "::" in new_ip :
20492049 if node .ipv6_address is None :
2050- raise Exception ("You should specity ipv6_address in add_node method" )
2050+ raise Exception ("You should specify ipv6_address in add_node method" )
20512051 self ._replace (node .docker_compose_path , node .ipv6_address , new_ip )
20522052 node .ipv6_address = new_ip
20532053 else :
20542054 if node .ipv4_address is None :
2055- raise Exception ("You should specity ipv4_address in add_node method" )
2055+ raise Exception ("You should specify ipv4_address in add_node method" )
20562056 self ._replace (node .docker_compose_path , node .ipv4_address , new_ip )
20572057 node .ipv4_address = new_ip
20582058 run_and_check (self .base_cmd + ["stop" , node .name ])
@@ -2119,9 +2119,11 @@ def exec_in_container(
21192119 detach : bool = False ,
21202120 nothrow : bool = False ,
21212121 use_cli : bool = True ,
2122+ get_exec_id : bool = False ,
21222123 ** kwargs : Any ,
21232124 ) -> str :
21242125 if use_cli :
2126+ assert not get_exec_id
21252127 logging .debug (
21262128 f"run container_id:{ container_id } detach:{ detach } nothrow:{ nothrow } cmd: { cmd } "
21272129 )
@@ -2159,8 +2161,9 @@ def exec_in_container(
21592161 else :
21602162 raise Exception (message )
21612163 if not detach :
2164+ assert not get_exec_id
21622165 return output .decode ()
2163- return output
2166+ return exec_id if get_exec_id else output
21642167
21652168 def copy_file_to_container (self , container_id , local_path , dest_path ):
21662169 with open (local_path , "rb" ) as fdata :
@@ -2732,7 +2735,7 @@ def wait_cassandra_to_start(self, timeout=180):
27322735 logging .info (
27332736 f"Check Cassandra Online { self .cassandra_id } { self .cassandra_ip } { self .cassandra_port } "
27342737 )
2735- check = self .exec_in_container (
2738+ self .exec_in_container (
27362739 self .cassandra_id ,
27372740 [
27382741 "bash" ,
@@ -4032,16 +4035,20 @@ def start_clickhouse(
40324035 )
40334036 start_time = time .time ()
40344037 time_to_sleep = 0.5
4038+ exec_id = None
40354039
40364040 while start_time + start_wait_sec >= time .time ():
40374041 # sometimes after SIGKILL (hard reset) server may refuse to start for some time
40384042 # for different reasons.
40394043 pid = self .get_process_pid ("clickhouse" )
40404044 if pid is None :
40414045 logging .debug ("No clickhouse process running. Start new one." )
4042- self .exec_in_container (
4043- ["bash" , "-c" , self .clickhouse_start_command_in_daemon ],
4046+ exec_id = self .exec_in_container (
4047+ ["bash" , "-c" , self .clickhouse_start_command ],
40444048 user = str (os .getuid ()),
4049+ detach = True ,
4050+ use_cli = False ,
4051+ get_exec_id = True ,
40454052 )
40464053 if expected_to_fail :
40474054 self .wait_start_failed (start_wait_sec + start_time - time .time ())
@@ -4054,7 +4061,7 @@ def start_clickhouse(
40544061 raise Exception ("ClickHouse was expected not to be running." )
40554062 try :
40564063 self .wait_start (start_wait_sec + start_time - time .time ())
4057- return
4064+ return exec_id
40584065 except Exception as e :
40594066 logging .warning (
40604067 f"Current start attempt failed. Will kill { pid } just in case."
0 commit comments