From cf7f24a6ec0f787c7788a85871fbbd99316064ef Mon Sep 17 00:00:00 2001 From: Derek Menteer Date: Wed, 31 Aug 2022 16:38:42 -0500 Subject: [PATCH] Change serf-tag references to field references. --- agent/consul/leader.go | 10 ++++------ agent/metadata/server.go | 41 +++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/agent/consul/leader.go b/agent/consul/leader.go index 0cc4260df0..29cd216c9f 100644 --- a/agent/consul/leader.go +++ b/agent/consul/leader.go @@ -1073,13 +1073,11 @@ func (s *Server) handleAliveMember(member serf.Member, nodeEntMeta *acl.Enterpri }, } - grpcPortStr := member.Tags["grpc_port"] - if v, err := strconv.Atoi(grpcPortStr); err == nil && v > 0 { - service.Meta["grpc_port"] = grpcPortStr + if parts.ExternalGRPCPort > 0 { + service.Meta["grpc_port"] = strconv.Itoa(parts.ExternalGRPCPort) } - grpcTLSPortStr := member.Tags["grpc_tls_port"] - if v, err := strconv.Atoi(grpcTLSPortStr); err == nil && v > 0 { - service.Meta["grpc_tls_port"] = grpcTLSPortStr + if parts.ExternalGRPCTLSPort > 0 { + service.Meta["grpc_tls_port"] = strconv.Itoa(parts.ExternalGRPCTLSPort) } // Attempt to join the consul server diff --git a/agent/metadata/server.go b/agent/metadata/server.go index 86f48749a1..bb0c263364 100644 --- a/agent/metadata/server.go +++ b/agent/metadata/server.go @@ -23,30 +23,27 @@ func (k *Key) Equal(x *Key) bool { // Server is used to return details of a consul server type Server struct { - Name string // . - ShortName string // - ID string - Datacenter string - Segment string - Port int - SegmentAddrs map[string]string - SegmentPorts map[string]int - WanJoinPort int - LanJoinPort int - - // TODO why are these ports needed? It looks like nothing is referencing them. + Name string // . + ShortName string // + ID string + Datacenter string + Segment string + Port int + SegmentAddrs map[string]string + SegmentPorts map[string]int + WanJoinPort int + LanJoinPort int ExternalGRPCPort int ExternalGRPCTLSPort int - - Bootstrap bool - Expect int - Build version.Version - Version int - RaftVersion int - Addr net.Addr - Status serf.MemberStatus - ReadReplica bool - FeatureFlags map[string]int + Bootstrap bool + Expect int + Build version.Version + Version int + RaftVersion int + Addr net.Addr + Status serf.MemberStatus + ReadReplica bool + FeatureFlags map[string]int // If true, use TLS when connecting to this server UseTLS bool