remove network calls for getLocalDisks (#11603)

This commit is contained in:
Harshavardhana 2021-02-22 13:19:44 -08:00 committed by GitHub
parent 18ec933085
commit da676ac298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 21 deletions

View File

@ -17,9 +17,11 @@
package cmd
import (
"context"
"net/http"
"time"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/madmin"
)
@ -46,10 +48,12 @@ func getLocalServerProperty(endpointServerPools EndpointServerPools, r *http.Req
}
_, present := network[nodeName]
if !present {
if err := isServerResolvable(endpoint, time.Second); err == nil {
if err := isServerResolvable(endpoint, 2*time.Second); err == nil {
network[nodeName] = "online"
} else {
network[nodeName] = "offline"
// log once the error
logger.LogOnceIf(context.Background(), err, nodeName)
}
}
}
@ -73,30 +77,15 @@ func getLocalServerProperty(endpointServerPools EndpointServerPools, r *http.Req
func getLocalDisks(endpointServerPools EndpointServerPools) []madmin.Disk {
var localEndpoints Endpoints
network := make(map[string]string)
for _, ep := range endpointServerPools {
for _, endpoint := range ep.Endpoints {
nodeName := endpoint.Host
if nodeName == "" {
nodeName = "localhost"
}
if endpoint.IsLocal {
// Only proceed for local endpoints
network[nodeName] = "online"
localEndpoints = append(localEndpoints, endpoint)
if !endpoint.IsLocal {
continue
}
_, present := network[nodeName]
if !present {
if err := isServerResolvable(endpoint, time.Second); err == nil {
network[nodeName] = "online"
} else {
network[nodeName] = "offline"
}
}
localEndpoints = append(localEndpoints, endpoint)
}
}
localDisks, _ := initStorageDisksWithErrors(localEndpoints)
defer closeStorageDisks(localDisks)
storageInfo, _ := getStorageInfo(localDisks, localEndpoints.GetAllStrings())

View File

@ -167,8 +167,7 @@ func isServerResolvable(endpoint Endpoint, timeout time.Duration) error {
var tlsConfig *tls.Config
if globalIsTLS {
tlsConfig = &tls.Config{
ServerName: endpoint.Hostname(),
RootCAs: globalRootCAs,
RootCAs: globalRootCAs,
}
}