Skip to content

FullSlots BackendEndpoint is incorrect #84

@EmpireJones

Description

@EmpireJones

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions