Skip to content

Commit ae4ad32

Browse files
author
Peng Zhou
committed
Fix bug in TCP config have wrong number of backend servers
1 parent 9ec1fa2 commit ae4ad32

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

pkg/k8sutil/haProxyHelper.go

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,16 @@ func generateHAProxyConfig(ctx context.Context, cr *marklogicv1.MarklogicCluster
114114
} else {
115115
key = fmt.Sprintf("%d-%d", tcpPort.Port, targetPort)
116116
}
117-
if _, exists := tcpMap[key]; exists {
118-
tcpMap[key] = append(tcpMap[key], TCPConfig{
119-
TcpName: key,
120-
Port: int(tcpPort.Port),
121-
TargetPort: targetPort,
122-
PortName: tcpPort.Name,
123-
PodName: group.Name,
124-
Replicas: int(*group.Replicas),
125-
GroupName: group.Name,
126-
})
127-
} else {
128-
tcpMap[key] = []TCPConfig{{
129-
TcpName: key,
130-
Port: int(tcpPort.Port),
131-
TargetPort: targetPort,
132-
PortName: tcpPort.Name,
133-
PodName: group.Name,
134-
Replicas: int(*group.Replicas),
135-
GroupName: group.Name,
136-
}}
117+
tcpConfig := TCPConfig{
118+
TcpName: key,
119+
Port: int(tcpPort.Port),
120+
TargetPort: targetPort,
121+
PortName: tcpPort.Name,
122+
PodName: group.Name,
123+
Replicas: int(*group.Replicas),
124+
GroupName: group.Name,
137125
}
126+
tcpMap[key] = append(tcpMap[key], tcpConfig)
138127
}
139128
}
140129

@@ -385,9 +374,8 @@ listen marklogic-TCP-{{.TcpName }}
385374
}
386375
result += parseTemplateToString(t, data)
387376
name := tcpConfigSlice[0].GroupName
388-
groupReplicas := int(tcpConfigSlice[0].Replicas)
389377
for _, tcpConfig := range tcpConfigSlice {
390-
for i := 0; i < groupReplicas; i++ {
378+
for i := 0; i < tcpConfig.Replicas; i++ {
391379
data := &HAProxyTemplate{
392380
PortNumber: int(tcpConfig.TargetPort),
393381
PodName: tcpConfig.PodName,

0 commit comments

Comments
 (0)