Skip to content

Commit

Permalink
[#24659] Update the change in master addresses list to refect in tser…
Browse files Browse the repository at this point in the history
…ver gflag.

Summary: Use Yb-ts-cli CLI for setting the tserver_master_addresses to immediately take effect when the list of master_addresses are updated in yugabyted.

Test Plan: ./yb_build.sh --java-test 'org.yb.yugabyted.TestYugabytedMultiZone.testMultiZone'

Reviewers: sgarg-yb

Reviewed By: sgarg-yb

Subscribers: yugabyted-dev

Differential Revision: https://phorge.dev.yugabyte.com/D39574
  • Loading branch information
nchandrappa committed Nov 6, 2024
1 parent f99d413 commit 50c512e
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions bin/yugabyted
Original file line number Diff line number Diff line change
Expand Up @@ -6110,6 +6110,13 @@ class ControlScript(object):
Output.log("thread-uml: master list updated, old list: {} ".format(
current_master_list) + "new list: {}".format(full_master_list))

tserver_ip_addr = self.advertise_ip()
tserver_ip_port = self.configs.saved_data.get("tserver_rpc_port")
if not YBTableServerCLIProxy.update_gflag_in_tserver(tserver_ip_addr,
tserver_ip_port, "tserver_master_addrs", masters_csv, True):
Output.log("Failed to update the master list {} " +
"on the tserver node.".format(masters_csv))

# Persist the config if masters have changed
self.configs.save_configs()

Expand Down Expand Up @@ -8357,13 +8364,19 @@ class ControlScript(object):
# Initialize the binary path of ybadmin
YBAdminProxy.init()

# Initialize the binary path of yb-ts-cli
YBTableServerCLIProxy.init()

self.validate_and_set_configs(args)

# Initialize the binary path of ybadmin
# TODO(Sanket): Clean up and refactor this file
YBAdminProxy.set_certs_dir(self.configs.saved_data.get("master_flags"), \
self.configs.saved_data.get("secure"), self.configs.saved_data.get("certs_dir"))

YBTableServerCLIProxy.set_certs_dir(self.configs.saved_data.get("master_flags"), \
self.configs.saved_data.get("secure"), self.configs.saved_data.get("certs_dir"))

try:
args.func()
except Exception as e:
Expand Down Expand Up @@ -8930,6 +8943,51 @@ class Diagnostics(object):
size += os.path.getsize(filepath)
return size

class YBTableServerCLIProxy(object):
cmd_args = []

@staticmethod
def init():
YBTableServerCLIProxy.cmd_args.append(find_binary_location("yb-ts-cli"))

@staticmethod
def set_certs_dir(master_flags, secure, certs_dir):
# If the user is attempting to use TLS, let's point yb-admin to
# the same certs dir as the master
if secure:
YBTableServerCLIProxy.cmd_args.append("--certs_dir_name={}".format(certs_dir))
elif master_flags:
flags_list = master_flags.split(",")
if 'use_node_to_node_encryption=true' not in flags_list:
return
certs_dir_name = [y for y in
[re.match('certs_dir=(.*)', x) for x in flags_list]
if y is not None]
if not certs_dir_name[0]:
raise RuntimeError("use_node_to_node_encryption=true must "
"be accompanied by a certs_dir setting")
YBTableServerCLIProxy.cmd_args.append('--certs_dir_name={}'.
format(certs_dir_name[0].group(1)))

@staticmethod
def update_gflag_in_tserver(tserver_ip, tserver_port, gflag, gflag_value, byForce=False):
cmd = YBTableServerCLIProxy.cmd_args + \
[
"--server_address={}:{}".format(tserver_ip, tserver_port),
"set_flag",
gflag,
gflag_value
]

if byForce:
cmd = cmd + \
[
"--force"
]

out, err, ret_code = run_process(cmd, timeout=10, log_cmd=True)
return (0 == ret_code)

class YBControllerCLIProxy(object):
cmd_args = []

Expand Down

0 comments on commit 50c512e

Please sign in to comment.