I believe in stats_socket.go:201 BackendEndpoint is getting a local memory address for endpoint, which is re-used for each iteration of the loop, meaning that all of the BackendEndpoints in FullSlots are set to the last of the list of endpoints:
// use addr:port as BackendServerName, don't generate empty slots
for _, endpoint := range updBackendsMap[backendName].Endpoints {
target := fmt.Sprintf("%s:%s", endpoint.Address, endpoint.Port)
newBackend.FullSlots[target] = types.HAProxyBackendSlot{
BackendServerName: target,
BackendEndpoint: &endpoint,
}
}
To fix this, you should be able to make a local copy of the object, and then take the address of that.
I believe in stats_socket.go:201 BackendEndpoint is getting a local memory address for endpoint, which is re-used for each iteration of the loop, meaning that all of the BackendEndpoints in FullSlots are set to the last of the list of endpoints:
To fix this, you should be able to make a local copy of the object, and then take the address of that.