From d7861a6cab02db58bea4235192d8c257f2a73069 Mon Sep 17 00:00:00 2001 From: Hu# Date: Mon, 19 Feb 2024 11:28:56 +0800 Subject: [PATCH] pdms: change get ms members return value (#5547) --- pkg/pdapi/pdapi.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pkg/pdapi/pdapi.go b/pkg/pdapi/pdapi.go index dd104487ef6..bc8d867e0cc 100644 --- a/pkg/pdapi/pdapi.go +++ b/pkg/pdapi/pdapi.go @@ -94,7 +94,7 @@ type PDClient interface { GetAutoscalingPlans(strategy Strategy) ([]Plan, error) // GetRecoveringMark return the pd recovering mark GetRecoveringMark() (bool, error) - // GetMSMembers returns all PD members from cluster by micro service + // GetMSMembers returns all PD members service-addr from cluster by specific Micro Service GetMSMembers(service string) ([]string, error) } @@ -198,6 +198,15 @@ type MembersInfo struct { EtcdLeader *pdpb.Member `json:"etcd_leader,omitempty"` } +// ServiceRegistryEntry is the registry entry of PD Micro Service +type ServiceRegistryEntry struct { + ServiceAddr string `json:"service-addr"` + Version string `json:"version"` + GitHash string `json:"git-hash"` + DeployPath string `json:"deploy-path"` + StartTimestamp int64 `json:"start-timestamp"` +} + // below copied from github.com/tikv/pd/pkg/autoscaling // Strategy within an HTTP request provides rules and resources to help make decision for auto scaling. @@ -320,12 +329,16 @@ func (c *pdClient) GetMSMembers(service string) ([]string, error) { if err != nil { return nil, err } - var members []string + var members []ServiceRegistryEntry err = json.Unmarshal(body, &members) if err != nil { return nil, err } - return members, nil + var addrs []string + for _, member := range members { + addrs = append(addrs, member.ServiceAddr) + } + return addrs, nil } func (c *pdClient) getStores(apiURL string) (*StoresInfo, error) {