diff --git a/weed/admin/dash/cluster_topology.go b/weed/admin/dash/cluster_topology.go index d70e32c44..dc6a49d4a 100644 --- a/weed/admin/dash/cluster_topology.go +++ b/weed/admin/dash/cluster_topology.go @@ -10,11 +10,10 @@ import ( "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" + util_http "github.com/seaweedfs/seaweedfs/weed/util/http" ) -var dirStatusClient = &http.Client{ - Timeout: 5 * time.Second, -} +const dirStatusTimeout = 5 * time.Second // GetClusterTopology returns the current cluster topology with caching func (s *AdminServer) GetClusterTopology() (*ClusterTopology, error) { @@ -50,8 +49,16 @@ func (s *AdminServer) fetchPublicUrlMap() map[string]string { return nil } + ctx, cancel := context.WithTimeout(context.Background(), dirStatusTimeout) + defer cancel() + url := fmt.Sprintf("http://%s/dir/status", currentMaster.ToHttpAddress()) - resp, err := dirStatusClient.Get(url) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + if err != nil { + glog.V(1).Infof("Failed to build /dir/status request for %s: %v", currentMaster, err) + return nil + } + resp, err := util_http.GetGlobalHttpClient().Do(req) if err != nil { glog.V(1).Infof("Failed to fetch /dir/status from %s: %v", currentMaster, err) return nil