Reroute requests based token heal/listing (#9939)

When manual healing is triggered, one node in a cluster will 
become the authority to heal. mc regularly sends new requests 
to fetch the status of the ongoing healing process, but a load 
balancer could land the healing request to a node that is not 
doing the healing request.

This PR will redirect a request to the node based on the node 
index found described as part of the client token. A similar
technique is also used to proxy ListObjectsV2 requests
by encoding this information in continuation-token
This commit is contained in:
Anis Elleuch
2020-07-03 19:53:03 +01:00
committed by GitHub
parent e59ee14f40
commit 2be20588bf
8 changed files with 144 additions and 73 deletions

View File

@@ -49,12 +49,11 @@ const (
URLEndpointType
)
// ListEndpoint - endpoint used for list redirects
// See proxyListRequest() for details.
type ListEndpoint struct {
host string
t *http.Transport
isLocal bool
// ProxyEndpoint - endpoint used for proxy redirects
// See proxyRequest() for details.
type ProxyEndpoint struct {
Endpoint
Transport *http.Transport
}
// Endpoint - any type of endpoint.
@@ -719,18 +718,21 @@ func GetRemotePeers(endpointZones EndpointZones) []string {
return peerSet.ToSlice()
}
// GetListEndpoints - get all endpoints that can be used to proxy list request.
func GetListEndpoints(endpointZones EndpointZones) ([]ListEndpoint, error) {
var listeps []ListEndpoint
listepExists := func(host string) bool {
for _, listep := range listeps {
if listep.host == host {
return true
}
// GetProxyEndpointLocalIndex returns index of the local proxy endpoint
func GetProxyEndpointLocalIndex(proxyEps []ProxyEndpoint) int {
for i, pep := range proxyEps {
if pep.IsLocal {
return i
}
return false
}
return -1
}
// GetProxyEndpoints - get all endpoints that can be used to proxy list request.
func GetProxyEndpoints(endpointZones EndpointZones) ([]ProxyEndpoint, error) {
var proxyEps []ProxyEndpoint
proxyEpSet := set.NewStringSet()
for _, ep := range endpointZones {
for _, endpoint := range ep.Endpoints {
@@ -739,28 +741,25 @@ func GetListEndpoints(endpointZones EndpointZones) ([]ListEndpoint, error) {
}
host := endpoint.Host
if listepExists(host) {
if proxyEpSet.Contains(host) {
continue
}
hostName, _, err := net.SplitHostPort(host)
if err != nil {
return nil, err
}
proxyEpSet.Add(host)
var tlsConfig *tls.Config
if globalIsSSL {
tlsConfig = &tls.Config{
ServerName: hostName,
ServerName: endpoint.Hostname(),
RootCAs: globalRootCAs,
}
}
listeps = append(listeps, ListEndpoint{
host,
newCustomHTTPTransport(tlsConfig, rest.DefaultRESTTimeout)(),
endpoint.IsLocal,
proxyEps = append(proxyEps, ProxyEndpoint{
Endpoint: endpoint,
Transport: newCustomHTTPTransport(tlsConfig, rest.DefaultRESTTimeout)(),
})
}
}
return listeps, nil
return proxyEps, nil
}
func updateDomainIPs(endPoints set.StringSet) {