Skip to content

Commit 59e080a

Browse files
committed
[#18572]yugabyted: Binding advertise_address to hostname for docker based deployments.
Summary: In docker based deployments, yugabyted by default binds to the ip_address of the container. When the hostname machine restarts, yugabyted fails to restart as the ip-address of the container would have changed. Updating the default behavior of yugabyted to bind with container `hostname` in docker deployments. ### Tests 1. Start yugabyted node docker ```sh docker run -d --name yugabyte --hostname yugabyte -p7000:7000 -p9000:9000 -p15433:15433 -p5433:5433 -p9042:9042 nchandrappa/yugabyte:2.25.0.0-hostname bin/yugabyted start --background=false ``` 2. Stop YB container ```sh docker stop <container-id> ``` 3. Start YB container ```sh docker start <container-id> ``` Jira: DB-7509 Test Plan: manual test Reviewers: sgarg-yb Reviewed By: sgarg-yb Subscribers: yugabyted-dev Differential Revision: https://phorge.dev.yugabyte.com/D39786
1 parent 6b28bfd commit 59e080a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

bin/yugabyted

+13-8
Original file line numberDiff line numberDiff line change
@@ -7555,15 +7555,20 @@ class ControlScript(object):
75557555

75567556
if args.advertise_address is None:
75577557
if not self.configs.saved_data.get("advertise_address"):
7558-
if OS_NAME == "Linux":
7559-
# Case Scenario: When advertise_address has no value in conf file
7560-
# and the OS is Linux, set the advertise address to the private IP
7561-
# of the machine.
7562-
args.advertise_address = self.find_ip_address_of_node()
7558+
7559+
if str(os.path.exists("/.dockerenv")):
7560+
args.advertise_address = self.find_hostname_of_node()
75637561
else:
7564-
# Case Scenario: When advertise_address has no value in conf file
7565-
# and the OS is Mac, set the advertise address to 127.0.0.1.
7566-
args.advertise_address = IP_LOCALHOST
7562+
if OS_NAME == "Linux":
7563+
# Case Scenario: When advertise_address has no value in conf file
7564+
# and the OS is Linux, set the advertise address to the private IP
7565+
# of the machine.
7566+
args.advertise_address = self.find_ip_address_of_node()
7567+
7568+
else:
7569+
# Case Scenario: When advertise_address has no value in conf file
7570+
# and the OS is Mac, set the advertise address to 127.0.0.1.
7571+
args.advertise_address = IP_LOCALHOST
75677572
else:
75687573
# Case Scenario: When advertise_address has a value in conf file and then
75697574
# use that regardless of the OS.

0 commit comments

Comments
 (0)