@@ -127,19 +127,52 @@ func (k *K8s) EventEndpoints(ns *Namespace, data *Endpoints, syncHAproxySrvs fun
127
127
ns .HAProxyRuntime [data .Service ] = make (map [string ]* RuntimeBackend )
128
128
}
129
129
logger .Tracef ("service %s : number of already existing backend(s) in this transaction for this endpoint: %d" , data .Service , len (ns .HAProxyRuntime [data .Service ]))
130
+ // Standalone
131
+ _ , ok = ns .HAProxyRuntimeStandalone [data .Service ]
132
+ if ! ok {
133
+ ns .HAProxyRuntimeStandalone [data .Service ] = make (map [string ]map [string ]* RuntimeBackend )
134
+ }
130
135
for key , value := range ns .HAProxyRuntime [data .Service ] {
131
136
logger .Tracef ("service %s : port name %s, backend %+v" , data .Service , key , * value )
132
137
}
138
+ // Standalone
139
+ for portName , backendsNames := range ns .HAProxyRuntimeStandalone [data .Service ] {
140
+ for backendName := range backendsNames {
141
+ logger .Tracef ("service %s : port name %s, backend %+v" , data .Service , portName , backendName )
142
+ }
143
+ }
133
144
for portName , portEndpoints := range endpoints {
145
+ // Make a copy of addresses for potential standalone runtime backend
146
+ // as these addresses are consumed/removed in the process
147
+ backendAddresses := utils .CopyMap (portEndpoints .Addresses )
134
148
newBackend := & RuntimeBackend {Endpoints : portEndpoints }
135
149
backend , ok := ns.HAProxyRuntime [data.Service ][portName ]
150
+ // Make a copy of haproxy server list for potential standalone runtime backend
151
+ // as this servere list is modified in the process
152
+ var backendHAProxySrvs []* HAProxySrv
136
153
if ok {
154
+ backendHAProxySrvs = utils .CopySliceFunc (backend .HAProxySrvs , utils .CopyPointer )
137
155
portUpdated := (newBackend .Endpoints .Port != backend .Endpoints .Port )
138
156
newBackend .HAProxySrvs = backend .HAProxySrvs
139
157
newBackend .Name = backend .Name
140
158
logger .Warning (syncHAproxySrvs (newBackend , portUpdated ))
141
159
}
142
160
ns.HAProxyRuntime [data.Service ][portName ] = newBackend
161
+
162
+ // Reprocuce the same steps ar regular runtime backend for each standalone runtime backend
163
+ // referring to the same port and service
164
+ standaloneNewBackend := & RuntimeBackend {Endpoints : portEndpoints }
165
+ for standaloneBackendName , standaloneRuntimeBackend := range ns.HAProxyRuntimeStandalone [data.Service ][portName ] {
166
+ // Make own copy of regular runtime backend portEndpoint addresses
167
+ standaloneNewBackend .Endpoints .Addresses = utils .CopyMap (backendAddresses )
168
+ // Make own copy of regular runtime backend portEndpoint servers list
169
+ standaloneNewBackend .HAProxySrvs = utils .CopySliceFunc (backendHAProxySrvs , utils .CopyPointer )
170
+ standaloneNewBackend .Name = standaloneRuntimeBackend .Name
171
+ standalonePortUpdated := (standaloneNewBackend .Endpoints .Port != standaloneRuntimeBackend .Endpoints .Port )
172
+ logger .Warning (syncHAproxySrvs (standaloneNewBackend , standalonePortUpdated ))
173
+ ns.HAProxyRuntimeStandalone [data.Service ][portName ][standaloneBackendName ] = standaloneNewBackend
174
+ standaloneNewBackend = & RuntimeBackend {Endpoints : portEndpoints }
175
+ }
143
176
}
144
177
return true
145
178
}
0 commit comments