@@ -1576,13 +1576,7 @@ def check_source_backrest_config(source_node_data):
1576
1576
"info"
1577
1577
)
1578
1578
else :
1579
- util .message (
1580
- f"Source node '{ source_node_data ['name' ]} ' does not have a BackRest configuration." ,
1581
- "info"
1582
- )
1583
- # Print the source node's path for debugging purposes
1584
- util .message (f"Source node path: { source_node_data ['path' ]} " , "info" )
1585
- # Remove any leftover BackRest configuration
1579
+
1586
1580
cmd = f"cd { source_node_data ['path' ]} /pgedge && ./pgedge remove backrest"
1587
1581
run_cmd (cmd , node = source_node_data , message = "Removing BackRest configuration from source node" , verbose = True )
1588
1582
@@ -1663,7 +1657,9 @@ def add_node(
1663
1657
"os_user" : os_user ,
1664
1658
"ssh_key" : ssh_key ,
1665
1659
}
1666
-
1660
+ # If backrest settings are provided in the JSON, add them to new_node_data.
1661
+ if backrest_info :
1662
+ new_node_data ["backrest" ] = backrest_info
1667
1663
if "public_ip" not in new_node_data and "private_ip" not in new_node_data :
1668
1664
util .exit_message (
1669
1665
"Both public_ip and private_ip are missing in target node data."
@@ -2039,6 +2035,52 @@ def add_node(
2039
2035
if v4 :
2040
2036
set_cluster_readonly (nodes , False , db [0 ]["db_name" ], f"pg{ pg } " , v4 , verbose )
2041
2037
2038
+ cmd = f'cd { new_node_data ["path" ]} /pgedge/; ./pgedge spock node-list { db [0 ]["db_name" ]} '
2039
+ message = f"Listing spock nodes"
2040
+ result = run_cmd (
2041
+ cmd , node = new_node_data , message = message , verbose = verbose , capture_output = True
2042
+ )
2043
+ print (f"\n { result .stdout } " )
2044
+
2045
+ sql_cmd = "select node_id,node_name from spock.node"
2046
+ cmd = (
2047
+ f"{ source_node_data ['path' ]} /pgedge/pgedge psql '{ sql_cmd } ' { db [0 ]['db_name' ]} "
2048
+ )
2049
+ message = f"List nodes"
2050
+ result = run_cmd (
2051
+ cmd ,
2052
+ node = source_node_data ,
2053
+ message = message ,
2054
+ verbose = verbose ,
2055
+ capture_output = True ,
2056
+ )
2057
+ print (f"\n { result .stdout } " )
2058
+
2059
+ for node in nodes :
2060
+ sql_cmd = (
2061
+ "select sub_id,sub_name,sub_enabled,sub_slot_name,"
2062
+ "sub_replication_sets from spock.subscription"
2063
+ )
2064
+ cmd = f"{ node ['path' ]} /pgedge/pgedge psql '{ sql_cmd } ' { db [0 ]['db_name' ]} "
2065
+ message = f"List subscriptions"
2066
+ result = run_cmd (
2067
+ cmd , node = node , message = message , verbose = verbose , capture_output = True
2068
+ )
2069
+ print (f"\n { result .stdout } " )
2070
+
2071
+ sql_cmd = (
2072
+ "select sub_id,sub_name,sub_enabled,sub_slot_name,"
2073
+ "sub_replication_sets from spock.subscription"
2074
+ )
2075
+ cmd = f"{ new_node_data ['path' ]} /pgedge/pgedge psql '{ sql_cmd } ' { db [0 ]['db_name' ]} "
2076
+ message = f"List subscriptions"
2077
+ result = run_cmd (
2078
+ cmd , node = new_node_data , message = message , verbose = verbose , capture_output = True
2079
+ )
2080
+ print (f"\n { result .stdout } " )
2081
+
2082
+
2083
+
2042
2084
# DEBUG: Reload the complete target JSON file and fetch repo1_path and stanza from its backrest settings.
2043
2085
try :
2044
2086
with open (target_node_file , "r" ) as f :
@@ -2179,7 +2221,20 @@ def add_node(
2179
2221
except Exception as e :
2180
2222
print (f"Error fetching values from target JSON file: { e } " )
2181
2223
# NEW: Check and display BackRest configuration status in the source node
2224
+ # Remove unnecessary keys before appending new node to the cluster data
2225
+ new_node_data .pop ("ip_address" , None )
2226
+ new_node_data .pop ("os_user" , None )
2227
+ new_node_data .pop ("ssh_key" , None )
2228
+
2229
+ # Append new node data to the cluster JSON
2230
+ node_group = target_node_data .get
2231
+ cluster_data ["node_groups" ].append (new_node_data )
2232
+ cluster_data ["update_date" ] = datetime .datetime .now ().astimezone ().isoformat ()
2233
+
2234
+ write_cluster_json (cluster_name , cluster_data )
2235
+
2182
2236
check_source_backrest_config (source_node_data )
2237
+
2183
2238
def capture_backrest_config (cluster_name , verbose = False ):
2184
2239
"""
2185
2240
Capture and clean BackRest configuration for all nodes (and sub-nodes) in the cluster
0 commit comments