mirror of
https://github.com/minio/minio.git
synced 2025-11-08 21:24:55 -05:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user