diff --git a/cli/cmd/endpoints.go b/cli/cmd/endpoints.go index 1e835d9188044..a25238b00b42b 100644 --- a/cli/cmd/endpoints.go +++ b/cli/cmd/endpoints.go @@ -37,6 +37,8 @@ type ( name string address string ip string + weight uint32 + labels map[string]string } ) @@ -200,6 +202,8 @@ func requestEndpointsFromAPI(client destinationPb.DestinationClient, authorities name: labels["pod"], address: tcpAddr.String(), ip: getIP(tcpAddr), + weight: addr.GetWeight(), + labels: addr.GetMetricLabels(), }) } } @@ -230,6 +234,9 @@ type rowEndpoint struct { Port uint32 `json:"port"` Pod string `json:"pod"` Service string `json:"service"` + Weight uint32 `json:"weight"` + + Labels map[string]string `json:"labels"` } func writeEndpointsToBuffer(endpoints endpointsInfo, w *tabwriter.Writer, options *endpointsOptions) { @@ -255,6 +262,8 @@ func writeEndpointsToBuffer(endpoints endpointsInfo, w *tabwriter.Writer, option Port: port, Pod: name, Service: serviceID, + Weight: pod.weight, + Labels: pod.labels, } endpointsTables[namespace] = append(endpointsTables[namespace], row) diff --git a/cli/cmd/endpoints_test.go b/cli/cmd/endpoints_test.go index 28acfba77c806..e30e90aa7fa4d 100644 --- a/cli/cmd/endpoints_test.go +++ b/cli/cmd/endpoints_test.go @@ -116,6 +116,8 @@ func TestEndpoints(t *testing.T) { } func testEndpointsCall(exp endpointsExp, t *testing.T) { + t.Helper() + updates := make([]pb.Update, 0) for _, endpoint := range exp.endpoints { addrSet := util.BuildAddrSet(endpoint) diff --git a/cli/cmd/testdata/endpoints_one_output_json.golden b/cli/cmd/testdata/endpoints_one_output_json.golden index 669a0389387bf..912a7da56cafc 100644 --- a/cli/cmd/testdata/endpoints_one_output_json.golden +++ b/cli/cmd/testdata/endpoints_one_output_json.golden @@ -4,13 +4,21 @@ "ip": "1.2.3.4", "port": 8080, "pod": "emoji-6bf9f47bd5-jjcrl", - "service": "emoji-svc.emojivoto" + "service": "emoji-svc.emojivoto", + "weight": 0, + "labels": { + "pod": "emoji-6bf9f47bd5-jjcrl" + } }, { "namespace": "emojivoto", "ip": "5.6.7.8", "port": 8080, "pod": "voting-7bf9f47bd5-jjdrl", - "service": "voting-svc.emojivoto" + "service": "voting-svc.emojivoto", + "weight": 0, + "labels": { + "pod": "voting-7bf9f47bd5-jjdrl" + } } ] diff --git a/test/integration/deep/endpoints/endpoints_test.go b/test/integration/deep/endpoints/endpoints_test.go index 88f6e6bb646b6..da34dd418f602 100644 --- a/test/integration/deep/endpoints/endpoints_test.go +++ b/test/integration/deep/endpoints/endpoints_test.go @@ -110,8 +110,10 @@ func createTestCaseTable(controlNs, endpointNs string) []testCase { "namespace": "(\S*)", "ip": "\d+\.\d+\.\d+\.\d+", "port": 8086, - "pod": "linkerd\-destination\-[a-f0-9]+\-[a-z0-9]+", - "service": "linkerd\-dst\.\S*" + "pod": "linkerd-destination\-[a-f0-9]+\-[a-z0-9]+", + "service": "linkerd-dst\.\S*", + "weight": \d+, + "labels": \{(?s).*\} \} \]`, ns: controlNs, @@ -124,8 +126,10 @@ func createTestCaseTable(controlNs, endpointNs string) []testCase { "namespace": "(\S*)", "ip": "\d+\.\d+\.\d+\.\d+", "port": 8080, - "pod": "linkerd\-identity\-[a-f0-9]+\-[a-z0-9]+", - "service": "linkerd\-identity\.\S*" + "pod": "linkerd-identity\-[a-f0-9]+\-[a-z0-9]+", + "service": "linkerd-identity\.\S*", + "weight": \d+, + "labels": \{(?s).*\} \} \]`, ns: controlNs, @@ -138,8 +142,10 @@ func createTestCaseTable(controlNs, endpointNs string) []testCase { "namespace": "(\S*)", "ip": "\d+\.\d+\.\d+\.\d+", "port": 8443, - "pod": "linkerd\-proxy\-injector-[a-f0-9]+\-[a-z0-9]+", - "service": "linkerd\-proxy\-injector\.\S*" + "pod": "linkerd-proxy-injector-[a-f0-9]+\-[a-z0-9]+", + "service": "linkerd-proxy-injector\.\S*", + "weight": \d+, + "labels": \{(?s).*\} \} \]`, ns: controlNs, @@ -152,8 +158,10 @@ func createTestCaseTable(controlNs, endpointNs string) []testCase { "namespace": "(\S*)", "ip": "\d+\.\d+\.\d+\.\d+", "port": 8080, - "pod": "nginx\-[a-f0-9]+\-[a-z0-9]+", - "service": "nginx\.\S*" + "pod": "nginx-[a-f0-9]+\-[a-z0-9]+", + "service": "nginx\.\S*", + "weight": \d+, + "labels": \{(?s).*\} \} \]`, ns: endpointNs,