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