From f407bdaa36ba5b02a60e79581cc147c28e3a88b0 Mon Sep 17 00:00:00 2001 From: Parviz Miriyev Date: Sun, 26 Apr 2026 23:25:53 +0400 Subject: [PATCH] fix(admin): use TLS-aware HTTP client for /dir/status fetch (#9227) fetchPublicUrlMap() in weed/admin/dash/cluster_topology.go uses a dedicated &http.Client{} that doesn't honor security.toml client TLS configuration, and hardcodes "http://" in the URL. When master is configured HTTPS-only ([https.master] set), every cluster topology cache refresh logs: NOTICE: http: TLS handshake error from :: client sent an HTTP request to an HTTPS server The function falls through to glog.V(1).Infof and returns nil, so the admin UI loses PublicUrl enrichment for data nodes. Cosmetic but noisy. Switch to util_http.GetGlobalHttpClient() whose Do() calls NormalizeHttpScheme(), which automatically rewrites http:// to https:// when [https.client] is enabled and presents the configured client cert. Preserve the 5-second timeout via context.WithTimeout(). Same pattern as weed/admin/handlers/file_browser_handlers.go, weed/server/master_server.go, weed/shell/command_volume_fsck.go. --- weed/admin/dash/cluster_topology.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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