From 356f710e4a371ac74e919d09a1653eaa81529b41 Mon Sep 17 00:00:00 2001 From: Hardy Date: Sat, 7 Dec 2024 17:13:32 +0800 Subject: [PATCH] fix: agent enroll failed (#15) --- modules/agent/api/elasticsearch.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/agent/api/elasticsearch.go b/modules/agent/api/elasticsearch.go index 2a3d2cf2..2f212d3d 100644 --- a/modules/agent/api/elasticsearch.go +++ b/modules/agent/api/elasticsearch.go @@ -31,6 +31,7 @@ import ( "context" "errors" "fmt" + "github.com/buger/jsonparser" log "github.com/cihub/seelog" "infini.sh/console/plugin/managed/server" httprouter "infini.sh/framework/core/api/router" @@ -661,6 +662,9 @@ func (h *APIHandler) getESNodeInfoViaProxy(esHost string, esSchema string, auth func (h *APIHandler) getESNodeInfoViaProxyWithConfig(cfg *elastic.ElasticsearchConfig, auth *model.BasicAuth, endpoint string) (success, tryAgain bool, info *elastic.LocalNodeInfo) { body := util.MustToJSONBytes(cfg) + if cfg.BasicAuth != nil { + body, _ = jsonparser.Set(body, []byte(`"`+cfg.BasicAuth.Password.Get()+`"`), "basic_auth", "password") + } ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() req := &util.Request{