@@ -525,6 +525,14 @@ def find_binary_location(binary_name):
525
525
os .path .join (YUGABYTE_DIR , "build" , "latest" , "gobin" ),
526
526
]
527
527
528
+ # Paths for pg_isready
529
+ dir_candidates .extend ([
530
+ # If tar is downloaded
531
+ os .path .join (YUGABYTE_DIR , "postgres" , "bin" ),
532
+ # Development environment
533
+ os .path .join (YUGABYTE_DIR , "build" , "debug-clang17-dynamic-ninja" , "postgres" , "bin" )
534
+ ])
535
+
528
536
# Jenkins Test Environment
529
537
dir_candidates += [
530
538
os .path .join (YUGABYTE_JENKINS_BUILD_DIR , "bin" )
@@ -1109,9 +1117,11 @@ class ControlScript(object):
1109
1117
def status (self ):
1110
1118
if len (os .listdir (self .configs .saved_data .get ("data_dir" ))) != 0 :
1111
1119
Output .init_animation ("Fetching status..." )
1112
- status_output = self .get_status_string (). strip ()
1120
+ status_output , ret_code = self .get_status_string ()
1113
1121
Output .update_animation ("" , Output .ANIMATION_STOP )
1114
- Output .print_out ("\n " + status_output )
1122
+ Output .print_out ("\n " + status_output .strip ())
1123
+ if ret_code :
1124
+ sys .exit (ret_code )
1115
1125
else :
1116
1126
Output .print_out ("{} is not running." .format (SCRIPT_NAME ))
1117
1127
@@ -3270,8 +3280,8 @@ class ControlScript(object):
3270
3280
warning_msg += "\n " + warning_help_msg
3271
3281
3272
3282
if is_first_run :
3273
- status = self .get_status_string () + \
3274
- "{} YugabyteDB started successfully! To load a sample dataset, " \
3283
+ status , _ = self .get_status_string ()
3284
+ status += "{} YugabyteDB started successfully! To load a sample dataset, " \
3275
3285
"try '{} demo'.\n " \
3276
3286
"{} Join us on Slack at {}\n " \
3277
3287
"{} Claim your free t-shirt at {}\n " .format (
@@ -3497,8 +3507,8 @@ class ControlScript(object):
3497
3507
warning_msg += "\n " + warning_help_msg
3498
3508
3499
3509
if is_first_run :
3500
- status = self .get_status_string () + \
3501
- "{} YugabyteDB started successfully! To load a sample dataset, " \
3510
+ status , _ = self .get_status_string ()
3511
+ status += "{} YugabyteDB started successfully! To load a sample dataset, " \
3502
3512
"try '{} demo'.\n " \
3503
3513
"{} Join us on Slack at {}\n " \
3504
3514
"{} Claim your free t-shirt at {}\n " .format (
@@ -5823,6 +5833,18 @@ class ControlScript(object):
5823
5833
Output .log ("Failed to login: {}" .format (err ))
5824
5834
return "Timeout: " + err
5825
5835
5836
+ def check_pg_isready (self , timeout = 5 , retries = 10 ):
5837
+ advertise_ip = self .advertise_ip ()
5838
+ path = find_binary_location ("pg_isready" )
5839
+ cmd = [path , "-h" , str (advertise_ip )]
5840
+
5841
+ (out , err , retcode ) = run_process_with_retries (cmd = cmd , log_cmd = True , retries = retries ,
5842
+ timeout = timeout )
5843
+ if retcode :
5844
+ return False
5845
+ else :
5846
+ return True
5847
+
5826
5848
# Returns pretty output table.
5827
5849
def get_status_string (self ):
5828
5850
@@ -5858,14 +5880,18 @@ class ControlScript(object):
5858
5880
5859
5881
status_info = []
5860
5882
status_display_info = dict ()
5883
+ ret_code = 0
5861
5884
# Make sure ascii escape characters for color encoding do not count towards char limit.
5862
5885
if self .get_failed_node_processes ():
5863
5886
title = Output .make_bold (Output .make_red (SCRIPT_NAME ))
5864
5887
extra_len = len (Output .make_bold (Output .make_red ("" )))
5865
5888
status = "Stopped"
5889
+ ysql_status = "Not Ready"
5866
5890
status_info = [
5867
5891
(Output .make_yellow ("Status" ), status ),
5892
+ (Output .make_yellow ("YSQL Status" ), ysql_status ),
5868
5893
]
5894
+ ret_code = 1
5869
5895
else :
5870
5896
title = Output .make_bold (Output .make_green (SCRIPT_NAME ))
5871
5897
extra_len = len (Output .make_bold (Output .make_green ("" )))
@@ -5875,17 +5901,39 @@ class ControlScript(object):
5875
5901
# the leader election
5876
5902
# In case of manual start or some other route, we can have a smaller timeout
5877
5903
status = ""
5904
+ if self .configs .temp_data .get ("yugabyted_cmd" ) == "start" :
5905
+ Output .init_animation ("Checking YSQL Status..." )
5906
+ pg_isready = self .check_pg_isready ()
5907
+ if self .configs .temp_data .get ("yugabyted_cmd" ) == "start" :
5908
+ Output .update_animation ("" , Output .ANIMATION_STOP )
5878
5909
if was_already_setup :
5879
5910
if master_addrs :
5880
5911
status = "Running."
5912
+ if pg_isready :
5913
+ ysql_status = "Ready"
5914
+ ret_code = 0
5915
+ else :
5916
+ ysql_status = "Not Ready"
5917
+ ret_code = 1
5918
+
5881
5919
else :
5882
5920
status = "Bootstrapping."
5921
+ ysql_status = "Not Ready"
5922
+ ret_code = 0
5883
5923
else :
5884
5924
if self .wait_get_all_masters (timeout = 10 ):
5885
5925
status = "Running."
5926
+ if pg_isready :
5927
+ ysql_status = "Ready"
5928
+ ret_code = 0
5929
+ else :
5930
+ ysql_status = "Not Ready"
5931
+ ret_code = 1
5886
5932
else :
5887
5933
status = "Status command timed out as YugabyteDB \" yb-master\" " + \
5888
5934
"process is not responding."
5935
+ ysql_status = "Not Ready"
5936
+ ret_code = 1
5889
5937
5890
5938
enabled_security_features = []
5891
5939
if self .configs .temp_data .get ("yugabyted_cmd" ) == "status" :
@@ -5913,7 +5961,10 @@ class ControlScript(object):
5913
5961
else :
5914
5962
rf = YBAdminProxy .get_cluster_rf (master_addrs )
5915
5963
5916
- status_info = [(Output .make_yellow ("Status" ), status )]
5964
+ status_info = [
5965
+ (Output .make_yellow ("Status" ), status ),
5966
+ (Output .make_yellow ("YSQL Status" ), ysql_status ),
5967
+ ]
5917
5968
if rf :
5918
5969
status_info .append ((Output .make_yellow ("Replication Factor" ), rf ))
5919
5970
@@ -6011,7 +6062,7 @@ class ControlScript(object):
6011
6062
format (v if v is not None else "None" )
6012
6063
6013
6064
status += div_line
6014
- return status
6065
+ return status , ret_code
6015
6066
6016
6067
# Returns pretty output table
6017
6068
def get_status_string_common (self , status_info , status_display_info = None ):
0 commit comments