Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix(admin): use TLS-aware HTTP client for /dir/status fetch (#9227)

Parviz Miriyevf407bdaa36ba
diff --git a/weed/admin/dash/cluster_topology.go b/weed/admin/dash/cluster_topology.go
index d70e32c442..dc6a49d4a4 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