Skip to content

Commit 6b9b4e8

Browse files
fix(compose): Calculate peer port considering learner nodes differences (#9507)
This PR changes how the compose tool calculates the port for zero1. It now combines the zeroBasePort (5080) with the opts.PortOffset (default 100) to get the correct peer port (5180). Previously, this calculation was incorrect, causing learner nodes to try and connect to zero1 on the wrong port.
1 parent 89bd082 commit 6b9b4e8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compose/compose.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ func getZero(idx int, raft string) service {
235235
if idx == 1 {
236236
svc.Command += " --bindall"
237237
} else {
238-
svc.Command += fmt.Sprintf(" --peer=%s:%d", name(basename, 1), basePort)
238+
peerPort := zeroBasePort + opts.PortOffset
239+
svc.Command += fmt.Sprintf(" --peer=%s:%d", name(basename, 1), peerPort)
239240
}
240241
if len(opts.MemLimit) > 0 {
241242
svc.Deploy.Resources = res{
@@ -258,7 +259,9 @@ func getZero(idx int, raft string) service {
258259

259260
func getAlpha(idx int, raft string) service {
260261
basename := "alpha"
262+
// internalPort is used for Raft communication between nodes.
261263
internalPort := alphaBasePort + opts.PortOffset + getOffset(idx)
264+
// grpcPort is the public-facing port for clients. It is offset from the internal port.
262265
grpcPort := internalPort + 1000
263266
svc := initService(basename, idx, grpcPort)
264267

0 commit comments

Comments
 (0)