mirror of
https://github.com/minio/minio.git
synced 2025-11-08 21:24:55 -05:00
fix: proxy ListObjects request to one of the server based on hash(bucket) (#9881)
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@@ -31,6 +33,7 @@ import (
|
||||
"github.com/minio/minio-go/v6/pkg/set"
|
||||
"github.com/minio/minio/cmd/config"
|
||||
"github.com/minio/minio/cmd/logger"
|
||||
"github.com/minio/minio/cmd/rest"
|
||||
"github.com/minio/minio/pkg/env"
|
||||
"github.com/minio/minio/pkg/mountinfo"
|
||||
)
|
||||
@@ -46,6 +49,14 @@ const (
|
||||
URLEndpointType
|
||||
)
|
||||
|
||||
// ListEndpoint - endpoint used for list redirects
|
||||
// See proxyListRequest() for details.
|
||||
type ListEndpoint struct {
|
||||
host string
|
||||
t *http.Transport
|
||||
isLocal bool
|
||||
}
|
||||
|
||||
// Endpoint - any type of endpoint.
|
||||
type Endpoint struct {
|
||||
*url.URL
|
||||
@@ -708,6 +719,50 @@ 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
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
for _, ep := range endpointZones {
|
||||
for _, endpoint := range ep.Endpoints {
|
||||
if endpoint.Type() != URLEndpointType {
|
||||
continue
|
||||
}
|
||||
|
||||
host := endpoint.Host
|
||||
if listepExists(host) {
|
||||
continue
|
||||
}
|
||||
hostName, _, err := net.SplitHostPort(host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var tlsConfig *tls.Config
|
||||
if globalIsSSL {
|
||||
tlsConfig = &tls.Config{
|
||||
ServerName: hostName,
|
||||
RootCAs: globalRootCAs,
|
||||
}
|
||||
}
|
||||
listeps = append(listeps, ListEndpoint{
|
||||
host,
|
||||
newCustomHTTPTransport(tlsConfig, rest.DefaultRESTTimeout)(),
|
||||
endpoint.IsLocal,
|
||||
})
|
||||
}
|
||||
}
|
||||
return listeps, nil
|
||||
}
|
||||
|
||||
func updateDomainIPs(endPoints set.StringSet) {
|
||||
ipList := set.NewStringSet()
|
||||
for e := range endPoints {
|
||||
|
||||
Reference in New Issue
Block a user