From 14b1fb9e53cb770f992924f33d5b0fdde9e5c5da Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Wed, 10 Aug 2022 11:42:04 -0400 Subject: [PATCH 01/13] Don't show 'non-domain' FQDNs --- cli/cmd/proxy/read/config.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/cmd/proxy/read/config.go b/cli/cmd/proxy/read/config.go index cc3fa8d7e5..38b8651d5e 100644 --- a/cli/cmd/proxy/read/config.go +++ b/cli/cmd/proxy/read/config.go @@ -219,9 +219,15 @@ func parseClusters(rawCfg map[string]interface{}, clusterMapping map[string][]st } } + // Don't display "non-domain name" FQDNs (e.g. local_app) + fqdn := cluster.Cluster.FQDN + if !strings.Contains(fqdn, ".") { + fqdn = "" + } + clusters = append(clusters, Cluster{ Name: strings.Split(cluster.Cluster.FQDN, ".")[0], - FullyQualifiedDomainName: cluster.Cluster.FQDN, + FullyQualifiedDomainName: fqdn, Endpoints: endpoints, Type: cluster.Cluster.ClusterType, LastUpdated: cluster.LastUpdated, @@ -257,7 +263,7 @@ func parseEndpoints(rawCfg map[string]interface{}, endpointMapping map[string]st endpoints = append(endpoints, Endpoint{ Address: address, - Cluster: cluster, + Cluster: strings.Split(cluster, ".")[0], Weight: lbEndpoint.LoadBalancingWeight, Status: lbEndpoint.HealthStatus, }) From 929b5f16158984644c38b6c7837c03acd920bed6 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Aug 2022 12:53:21 -0400 Subject: [PATCH 02/13] Show message about no pods being found --- cli/cmd/proxy/list/command.go | 39 +++++++++++++++++++----------- cli/cmd/proxy/list/command_test.go | 29 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/cli/cmd/proxy/list/command.go b/cli/cmd/proxy/list/command.go index 9d62351857..ee29864728 100644 --- a/cli/cmd/proxy/list/command.go +++ b/cli/cmd/proxy/list/command.go @@ -21,7 +21,6 @@ type ListCommand struct { *common.BaseCommand kubernetes kubernetes.Interface - namespace string set *flag.Sets @@ -129,8 +128,7 @@ func (c *ListCommand) validateFlags() error { return nil } -// initKubernetes initializes the Kubernetes client and sets the namespace based -// on the user-provided arguments. +// initKubernetes initializes the Kubernetes client func (c *ListCommand) initKubernetes() error { settings := helmCLI.New() @@ -150,15 +148,19 @@ func (c *ListCommand) initKubernetes() error { return fmt.Errorf("error creating Kubernetes client %v", err) } + return err +} + +func (c *ListCommand) namespace() string { + settings := helmCLI.New() + if c.flagAllNamespaces { - c.namespace = "" // An empty namespace means all namespaces. + return "" // An empty namespace means all namespaces. } else if c.flagNamespace != "" { - c.namespace = c.flagNamespace + return c.flagNamespace } else { - c.namespace = settings.Namespace() + return settings.Namespace() } - - return err } // fetchPods fetches all pods in flagNamespace which run Consul proxies. @@ -166,7 +168,7 @@ func (c *ListCommand) fetchPods() ([]v1.Pod, error) { var pods []v1.Pod // Fetch all pods in the namespace with labels matching the gateway component names. - gatewaypods, err := c.kubernetes.CoreV1().Pods(c.namespace).List(c.Ctx, metav1.ListOptions{ + gatewaypods, err := c.kubernetes.CoreV1().Pods(c.namespace()).List(c.Ctx, metav1.ListOptions{ LabelSelector: "component in (ingress-gateway, mesh-gateway, terminating-gateway), chart=consul-helm", }) if err != nil { @@ -175,7 +177,7 @@ func (c *ListCommand) fetchPods() ([]v1.Pod, error) { pods = append(pods, gatewaypods.Items...) // Fetch all pods in the namespace with a label indicating they are an API gateway. - apigatewaypods, err := c.kubernetes.CoreV1().Pods(c.namespace).List(c.Ctx, metav1.ListOptions{ + apigatewaypods, err := c.kubernetes.CoreV1().Pods(c.namespace()).List(c.Ctx, metav1.ListOptions{ LabelSelector: "api-gateway.consul.hashicorp.com/managed=true", }) if err != nil { @@ -184,7 +186,7 @@ func (c *ListCommand) fetchPods() ([]v1.Pod, error) { pods = append(pods, apigatewaypods.Items...) // Fetch all pods in the namespace with a label indicating they are a service networked by Consul. - sidecarpods, err := c.kubernetes.CoreV1().Pods(c.namespace).List(c.Ctx, metav1.ListOptions{ + sidecarpods, err := c.kubernetes.CoreV1().Pods(c.namespace()).List(c.Ctx, metav1.ListOptions{ LabelSelector: "consul.hashicorp.com/connect-inject-status=injected", }) if err != nil { @@ -197,10 +199,19 @@ func (c *ListCommand) fetchPods() ([]v1.Pod, error) { // output prints a table of pods to the terminal. func (c *ListCommand) output(pods []v1.Pod) { + if len(pods) == 0 { + if c.flagAllNamespaces { + c.UI.Output("No proxies found across all namespaces.") + } else { + c.UI.Output("No proxies found in %s namespace.", c.namespace()) + } + return + } + if c.flagAllNamespaces { - c.UI.Output("Namespace: All Namespaces\n") - } else if c.namespace != "" { - c.UI.Output("Namespace: %s\n", c.namespace) + c.UI.Output("Namespace: all namespaces") + } else { + c.UI.Output("Namespace: %s", c.namespace()) } var tbl *terminal.Table diff --git a/cli/cmd/proxy/list/command_test.go b/cli/cmd/proxy/list/command_test.go index df6aaf024b..21507472ce 100644 --- a/cli/cmd/proxy/list/command_test.go +++ b/cli/cmd/proxy/list/command_test.go @@ -308,6 +308,35 @@ func TestListCommandOutput(t *testing.T) { } } +func TestNoPodsFound(t *testing.T) { + cases := map[string]struct { + args []string + expected string + }{ + "Default namespace": { + []string{"-n", "default"}, + "No proxies found in default namespace.", + }, + "All namespaces": { + []string{"-A"}, + "No proxies found across all namespaces.", + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + buf := new(bytes.Buffer) + c := setupCommand(buf) + c.kubernetes = fake.NewSimpleClientset() + + out := c.Run(tc.args) + require.Equal(t, 0, out) + + require.Regexp(t, tc.expected, buf.String()) + }) + } +} + func setupCommand(buf io.Writer) *ListCommand { // Log at a test level to standard out. log := hclog.New(&hclog.LoggerOptions{ From 97addce0c805167790ace7641dfe16b9490bf944 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Aug 2022 15:53:36 -0400 Subject: [PATCH 03/13] Fix tests for not showing "non-domain" FQDNs --- cli/cmd/proxy/list/command_test.go | 3 + cli/cmd/proxy/read/command_test.go | 44 +- cli/cmd/proxy/read/config_test.go | 151 +----- cli/cmd/proxy/read/test_clusters.json | 655 +++++++++++++---------- cli/cmd/proxy/read/test_config_dump.json | 254 ++------- 5 files changed, 444 insertions(+), 663 deletions(-) diff --git a/cli/cmd/proxy/list/command_test.go b/cli/cmd/proxy/list/command_test.go index 21507472ce..34c776cd2a 100644 --- a/cli/cmd/proxy/list/command_test.go +++ b/cli/cmd/proxy/list/command_test.go @@ -209,6 +209,9 @@ func TestFetchPods(t *testing.T) { c := setupCommand(new(bytes.Buffer)) c.kubernetes = fake.NewSimpleClientset(&v1.PodList{Items: tc.pods}) c.flagNamespace = tc.namespace + if tc.namespace == "" { + c.flagAllNamespaces = true + } pods, err := c.fetchPods() diff --git a/cli/cmd/proxy/read/command_test.go b/cli/cmd/proxy/read/command_test.go index 5295484be8..be9e226bb4 100644 --- a/cli/cmd/proxy/read/command_test.go +++ b/cli/cmd/proxy/read/command_test.go @@ -61,44 +61,38 @@ func TestReadCommandOutput(t *testing.T) { // These regular expressions must be present in the output. expectedHeader := fmt.Sprintf("Envoy configuration for %s in namespace default:", podName) expected := map[string][]string{ - "-clusters": {"==> Clusters \\(6\\)", + "-clusters": {"==> Clusters \\(5\\)", "Name.*FQDN.*Endpoints.*Type.*Last Updated", - "local_agent.*local_agent.*192\\.168\\.79\\.187:8502.*STATIC.*2022-05-13T04:22:39\\.553Z", - "local_app.*local_app.*127\\.0\\.0\\.1:8080.*STATIC.*2022-05-13T04:22:39\\.655Z", - "client.*client\\.default\\.dc1\\.internal\\.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00\\.consul.*EDS.*2022-06-09T00:39:12\\.948Z", - "frontend.*frontend\\.default\\.dc1\\.internal\\.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00\\.consul.*EDS.*2022-06-09T00:39:12\\.855Z", - "original-destination.*original-destination.*ORIGINAL_DST.*2022-05-13T04:22:39.743Z", - "server.*server.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul.*EDS.*2022-06-09T00:39:12\\.754Z"}, - - "-endpoints": {"==> Endpoints \\(9\\)", + "local_agent.*192\\.168\\.79\\.187:8502.*STATIC.*2022-05-13T04:22:39\\.553Z", + "local_app.*127\\.0\\.0\\.1:8080.*STATIC.*2022-05-13T04:22:39\\.655Z", + "client.*client\\.default\\.dc1\\.internal\\.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00\\.consul.*EDS", + "frontend.*frontend\\.default\\.dc1\\.internal\\.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00\\.consul", + "original-destination.*ORIGINAL_DST"}, + + "-endpoints": {"==> Endpoints \\(6\\)", "Address:Port.*Cluster.*Weight.*Status", "192.168.79.187:8502.*local_agent.*1.00.*HEALTHY", "127.0.0.1:8080.*local_app.*1.00.*HEALTHY", - "192.168.31.201:20000.*1.00.*HEALTHY", - "192.168.47.235:20000.*1.00.*HEALTHY", - "192.168.71.254:20000.*1.00.*HEALTHY", - "192.168.63.120:20000.*1.00.*HEALTHY", - "192.168.18.110:20000.*1.00.*HEALTHY", - "192.168.52.101:20000.*1.00.*HEALTHY", - "192.168.65.131:20000.*1.00.*HEALTHY"}, + "192.168.18.110:20000.*client.*1.00.*HEALTHY", + "192.168.52.101:20000.*client.*1.00.*HEALTHY", + "192.168.65.131:20000.*client.*1.00.*HEALTHY", + "192.168.63.120:20000.*frontend.*1.00.*HEALTHY"}, "-listeners": {"==> Listeners \\(2\\)", "Name.*Address:Port.*Direction.*Filter Chain Match.*Filters.*Last Updated", - "public_listener.*192\\.168\\.69\\.179:20000.*INBOUND.*Any.*\\* to local_app/.*2022-06-09T00:39:27\\.668Z", - "outbound_listener.*127.0.0.1:15001.*OUTBOUND.*10\\.100\\.134\\.173/32, 240\\.0\\.0\\.3/32.*to client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul.*2022-05-24T17:41:59\\.079Z", - "10\\.100\\.254\\.176/32, 240\\.0\\.0\\.4/32.*\\* to server\\.default\\.dc1\\.internal\\.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00\\.consul/", - "10\\.100\\.31\\.2/32, 240\\.0\\.0\\.2/32.*to frontend\\.default\\.dc1\\.internal\\.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00\\.consul", + "public_listener.*192\\.168\\.69\\.179:20000.*INBOUND.*Any.*\\* to local_app/", + "outbound_listener.*127.0.0.1:15001.*OUTBOUND.*10\\.100\\.134\\.173/32, 240\\.0\\.0\\.3/32.*to client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", + "10\\.100\\.31\\.2/32, 240\\.0\\.0\\.5/32.*to frontend\\.default\\.dc1\\.internal\\.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00\\.consul", "Any.*to original-destination"}, - "-routes": {"==> Routes \\(2\\)", + "-routes": {"==> Routes \\(1\\)", "Name.*Destination Cluster.*Last Updated", - "public_listener.*local_app/.*2022-06-09T00:39:27.667Z", - "server.*server\\.default\\.dc1\\.internal\\.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00\\.consul/.*2022-05-24T17:41:59\\.078Z"}, + "public_listener.*local_app/"}, "-secrets": {"==> Secrets \\(2\\)", "Name.*Type.*Last Updated", - "default.*Dynamic Active.*2022-05-24T17:41:59.078Z", - "ROOTCA.*Dynamic Warming.*2022-03-15T05:14:22.868Z"}, + "default.*Dynamic Active", + "ROOTCA.*Dynamic Warming"}, } cases := map[string][]string{ diff --git a/cli/cmd/proxy/read/config_test.go b/cli/cmd/proxy/read/config_test.go index cce3c4c12a..33a90b01c9 100644 --- a/cli/cmd/proxy/read/config_test.go +++ b/cli/cmd/proxy/read/config_test.go @@ -102,148 +102,33 @@ func rawEnvoyConfig(t *testing.T) []byte { // testEnvoyConfig is what we expect the config at `test_config_dump.json` to be. var testEnvoyConfig = &EnvoyConfig{ Clusters: []Cluster{ - { - Name: "local_agent", - FullyQualifiedDomainName: "local_agent", - Endpoints: []string{"192.168.79.187:8502", "172.18.0.2:8502"}, - Type: "STATIC", - LastUpdated: "2022-05-13T04:22:39.553Z", - }, - { - Name: "client", - FullyQualifiedDomainName: "client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", - Endpoints: []string{}, - Type: "EDS", - LastUpdated: "2022-06-09T00:39:12.948Z", - }, - { - Name: "frontend", - FullyQualifiedDomainName: "frontend.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", - Endpoints: []string{}, - Type: "EDS", - LastUpdated: "2022-06-09T00:39:12.855Z", - }, - { - Name: "local_app", - FullyQualifiedDomainName: "local_app", - Endpoints: []string{"127.0.0.1:8080", "127.0.0.1:0"}, - Type: "STATIC", - LastUpdated: "2022-05-13T04:22:39.655Z", - }, - { - Name: "original-destination", - FullyQualifiedDomainName: "original-destination", - Endpoints: []string{}, - Type: "ORIGINAL_DST", - LastUpdated: "2022-05-13T04:22:39.743Z", - }, - { - Name: "server", - FullyQualifiedDomainName: "server.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", - Endpoints: []string{}, - Type: "EDS", - LastUpdated: "2022-06-09T00:39:12.754Z", - }, + {Name: "local_agent", Endpoints: []string{"192.168.79.187:8502"}, Type: "STATIC", LastUpdated: "2022-05-13T04:22:39.553Z"}, + {Name: "client", FullyQualifiedDomainName: "client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", Endpoints: []string{"192.168.18.110:20000", "192.168.52.101:20000", "192.168.65.131:20000"}, Type: "EDS", LastUpdated: "2022-08-10T12:30:32.326Z"}, + {Name: "frontend", FullyQualifiedDomainName: "frontend.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", Endpoints: []string{"192.168.63.120:20000"}, Type: "EDS", LastUpdated: "2022-08-10T12:30:32.233Z"}, + {Name: "local_app", Endpoints: []string{"127.0.0.1:8080"}, Type: "STATIC", LastUpdated: "2022-05-13T04:22:39.655Z"}, + {Name: "original-destination", Endpoints: []string{}, Type: "ORIGINAL_DST", LastUpdated: "2022-05-13T04:22:39.743Z"}, }, Endpoints: []Endpoint{ - { - Address: "192.168.79.187:8502", - Cluster: "local_agent", - Weight: 1, - Status: "HEALTHY", - }, - { - Address: "127.0.0.1:8080", - Cluster: "local_app", - Weight: 1, - Status: "HEALTHY", - }, - { - Address: "192.168.31.201:20000", - Weight: 1, - Status: "HEALTHY", - }, - { - Address: "192.168.47.235:20000", - Weight: 1, - Status: "HEALTHY", - }, - { - Address: "192.168.71.254:20000", - Weight: 1, - Status: "HEALTHY", - }, - { - Address: "192.168.63.120:20000", - Weight: 1, - Status: "HEALTHY", - }, - { - Address: "192.168.18.110:20000", - Weight: 1, - Status: "HEALTHY", - }, - { - Address: "192.168.52.101:20000", - Weight: 1, - Status: "HEALTHY", - }, - { - Address: "192.168.65.131:20000", - Weight: 1, - Status: "HEALTHY", - }, + {Address: "192.168.79.187:8502", Cluster: "local_agent", Weight: 1, Status: "HEALTHY"}, + {Address: "192.168.18.110:20000", Cluster: "client", Weight: 1, Status: "HEALTHY"}, + {Address: "192.168.52.101:20000", Cluster: "client", Weight: 1, Status: "HEALTHY"}, + {Address: "192.168.65.131:20000", Cluster: "client", Weight: 1, Status: "HEALTHY"}, + {Address: "192.168.63.120:20000", Cluster: "frontend", Weight: 1, Status: "HEALTHY"}, + {Address: "127.0.0.1:8080", Cluster: "local_app", Weight: 1, Status: "HEALTHY"}, }, Listeners: []Listener{ - { - Name: "public_listener", - Address: "192.168.69.179:20000", - FilterChain: []FilterChain{ - { - FilterChainMatch: "Any", - Filters: []string{"* to local_app/"}, - }, - }, - Direction: "INBOUND", - LastUpdated: "2022-06-09T00:39:27.668Z", - }, - { - Name: "outbound_listener", - Address: "127.0.0.1:15001", - FilterChain: []FilterChain{ - { - FilterChainMatch: "10.100.134.173/32, 240.0.0.3/32", - Filters: []string{"to client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul"}, - }, - { - FilterChainMatch: "10.100.254.176/32, 240.0.0.4/32", - Filters: []string{"* to server.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul/"}, - }, - { - FilterChainMatch: "10.100.31.2/32, 240.0.0.2/32", - Filters: []string{ - "to frontend.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", - }, - }, - { - FilterChainMatch: "Any", - Filters: []string{"to original-destination"}, - }, - }, - Direction: "OUTBOUND", - LastUpdated: "2022-05-24T17:41:59.079Z", - }, + {Name: "public_listener", Address: "192.168.69.179:20000", FilterChain: []FilterChain{{Filters: []string{"* to local_app/"}, FilterChainMatch: "Any"}}, Direction: "INBOUND", LastUpdated: "2022-08-10T12:30:47.142Z"}, + {Name: "outbound_listener", Address: "127.0.0.1:15001", FilterChain: []FilterChain{ + {Filters: []string{"to client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul"}, FilterChainMatch: "10.100.134.173/32, 240.0.0.3/32"}, + {Filters: []string{"to frontend.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul"}, FilterChainMatch: "10.100.31.2/32, 240.0.0.5/32"}, + {Filters: []string{"to original-destination"}, FilterChainMatch: "Any"}, + }, Direction: "OUTBOUND", LastUpdated: "2022-07-18T15:31:03.246Z"}, }, Routes: []Route{ { Name: "public_listener", DestinationCluster: "local_app/", - LastUpdated: "2022-06-09T00:39:27.667Z", - }, - { - Name: "server", - DestinationCluster: "server.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul/", - LastUpdated: "2022-05-24T17:41:59.078Z", + LastUpdated: "2022-08-10T12:30:47.141Z", }, }, Secrets: []Secret{ diff --git a/cli/cmd/proxy/read/test_clusters.json b/cli/cmd/proxy/read/test_clusters.json index 55a4c244b2..83b52f3162 100644 --- a/cli/cmd/proxy/read/test_clusters.json +++ b/cli/cmd/proxy/read/test_clusters.json @@ -1,302 +1,373 @@ { - "cluster_statuses": [ + "cluster_statuses": [ + { + "name": "client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", + "added_via_api": true, + "host_statuses": [ { - "name": "local_app", - "added_via_api": true, - "host_statuses": [ - { - "address": { - "socket_address": { - "address": "127.0.0.1", - "port_value": 0 - } - }, - "stats": [ - { - "value": "6", - "name": "cx_connect_fail" - }, - { - "value": "38", - "name": "cx_total" - }, - { - "name": "rq_error" - }, - { - "name": "rq_success" - }, - { - "name": "rq_timeout" - }, - { - "name": "rq_total" - }, - { - "type": "GAUGE", - "name": "cx_active" - }, - { - "type": "GAUGE", - "name": "rq_active" - } - ], - "health_status": { - "eds_health_status": "HEALTHY" - }, - "weight": 1, - "locality": { - - } - } - ], - "circuit_breakers": { - "thresholds": [ - { - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - }, - { - "priority": "HIGH", - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - } - ] - }, - "observability_name": "local_app" + "address": { + "socket_address": { + "address": "192.168.18.110", + "port_value": 20000 + } + }, + "stats": [ + { + "name": "cx_connect_fail" + }, + { + "name": "cx_total" + }, + { + "name": "rq_error" + }, + { + "name": "rq_success" + }, + { + "name": "rq_timeout" + }, + { + "name": "rq_total" + }, + { + "type": "GAUGE", + "name": "cx_active" + }, + { + "type": "GAUGE", + "name": "rq_active" + } + ], + "health_status": { + "eds_health_status": "HEALTHY" + }, + "weight": 1, + "locality": {} }, { - "name": "self_admin", - "host_statuses": [ - { - "address": { - "socket_address": { - "address": "127.0.0.1", - "port_value": 19000 - } - }, - "stats": [ - { - "name": "cx_connect_fail" - }, - { - "value": "1", - "name": "cx_total" - }, - { - "name": "rq_error" - }, - { - "value": "26", - "name": "rq_success" - }, - { - "name": "rq_timeout" - }, - { - "value": "26", - "name": "rq_total" - }, - { - "type": "GAUGE", - "value": "1", - "name": "cx_active" - }, - { - "type": "GAUGE", - "name": "rq_active" - } - ], - "health_status": { - "eds_health_status": "HEALTHY" - }, - "weight": 1, - "locality": { - - } - } - ], - "circuit_breakers": { - "thresholds": [ - { - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - }, - { - "priority": "HIGH", - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - } - ] - }, - "observability_name": "self_admin" + "address": { + "socket_address": { + "address": "192.168.52.101", + "port_value": 20000 + } + }, + "stats": [ + { + "name": "cx_connect_fail" + }, + { + "name": "cx_total" + }, + { + "name": "rq_error" + }, + { + "name": "rq_success" + }, + { + "name": "rq_timeout" + }, + { + "name": "rq_total" + }, + { + "type": "GAUGE", + "name": "cx_active" + }, + { + "type": "GAUGE", + "name": "rq_active" + } + ], + "health_status": { + "eds_health_status": "HEALTHY" + }, + "weight": 1, + "locality": {} }, { - "name": "original-destination", - "added_via_api": true, - "circuit_breakers": { - "thresholds": [ - { - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - }, - { - "priority": "HIGH", - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - } - ] - }, - "observability_name": "original-destination" - }, + "address": { + "socket_address": { + "address": "192.168.65.131", + "port_value": 20000 + } + }, + "stats": [ + { + "name": "cx_connect_fail" + }, + { + "name": "cx_total" + }, + { + "name": "rq_error" + }, + { + "name": "rq_success" + }, + { + "name": "rq_timeout" + }, + { + "name": "rq_total" + }, + { + "type": "GAUGE", + "name": "cx_active" + }, + { + "type": "GAUGE", + "name": "rq_active" + } + ], + "health_status": { + "eds_health_status": "HEALTHY" + }, + "weight": 1, + "locality": {} + } + ], + "circuit_breakers": { + "thresholds": [ + { + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + }, + { + "priority": "HIGH", + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + } + ] + }, + "observability_name": "client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul" + }, + { + "name": "frontend.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", + "added_via_api": true, + "host_statuses": [ { - "name": "static-server.default.dc1.internal.80d0b664-149b-52fa-c6ae-3dad962bdaa8.consul", - "added_via_api": true, - "host_statuses": [ - { - "address": { - "socket_address": { - "address": "10.244.0.74", - "port_value": 20000 - } - }, - "stats": [ - { - "name": "cx_connect_fail" - }, - { - "name": "cx_total" - }, - { - "name": "rq_error" - }, - { - "name": "rq_success" - }, - { - "name": "rq_timeout" - }, - { - "name": "rq_total" - }, - { - "type": "GAUGE", - "name": "cx_active" - }, - { - "type": "GAUGE", - "name": "rq_active" - } - ], - "health_status": { - "eds_health_status": "HEALTHY" - }, - "weight": 1, - "locality": { - - } - } - ], - "circuit_breakers": { - "thresholds": [ - { - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - }, - { - "priority": "HIGH", - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - } - ] - }, - "observability_name": "static-server.default.dc1.internal.80d0b664-149b-52fa-c6ae-3dad962bdaa8.consul" - }, + "address": { + "socket_address": { + "address": "192.168.63.120", + "port_value": 20000 + } + }, + "stats": [ + { + "name": "cx_connect_fail" + }, + { + "name": "cx_total" + }, + { + "name": "rq_error" + }, + { + "name": "rq_success" + }, + { + "name": "rq_timeout" + }, + { + "name": "rq_total" + }, + { + "type": "GAUGE", + "name": "cx_active" + }, + { + "type": "GAUGE", + "name": "rq_active" + } + ], + "health_status": { + "eds_health_status": "HEALTHY" + }, + "weight": 1, + "locality": {} + } + ], + "circuit_breakers": { + "thresholds": [ + { + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + }, + { + "priority": "HIGH", + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + } + ] + }, + "observability_name": "frontend.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul" + }, + { + "name": "original-destination", + "added_via_api": true, + "circuit_breakers": { + "thresholds": [ + { + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + }, + { + "priority": "HIGH", + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + } + ] + }, + "observability_name": "original-destination" + }, + { + "name": "local_app", + "added_via_api": true, + "host_statuses": [ + { + "address": { + "socket_address": { + "address": "127.0.0.1", + "port_value": 8080 + } + }, + "stats": [ + { + "name": "cx_connect_fail" + }, + { + "name": "cx_total" + }, + { + "name": "rq_error" + }, + { + "name": "rq_success" + }, + { + "name": "rq_timeout" + }, + { + "name": "rq_total" + }, + { + "type": "GAUGE", + "name": "cx_active" + }, + { + "type": "GAUGE", + "name": "rq_active" + } + ], + "health_status": { + "eds_health_status": "HEALTHY" + }, + "weight": 1, + "locality": {} + } + ], + "circuit_breakers": { + "thresholds": [ + { + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + }, + { + "priority": "HIGH", + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + } + ] + }, + "observability_name": "local_app" + }, + { + "name": "local_agent", + "host_statuses": [ { - "name": "local_agent", - "host_statuses": [ - { - "address": { - "socket_address": { - "address": "172.18.0.2", - "port_value": 8502 - } - }, - "stats": [ - { - "name": "cx_connect_fail" - }, - { - "value": "1", - "name": "cx_total" - }, - { - "name": "rq_error" - }, - { - "name": "rq_success" - }, - { - "name": "rq_timeout" - }, - { - "value": "1", - "name": "rq_total" - }, - { - "type": "GAUGE", - "value": "1", - "name": "cx_active" - }, - { - "type": "GAUGE", - "value": "1", - "name": "rq_active" - } - ], - "health_status": { - "eds_health_status": "HEALTHY" - }, - "weight": 1, - "locality": { - - } - } - ], - "circuit_breakers": { - "thresholds": [ - { - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - }, - { - "priority": "HIGH", - "max_connections": 1024, - "max_pending_requests": 1024, - "max_requests": 1024, - "max_retries": 3 - } - ] - }, - "observability_name": "local_agent" + "address": { + "socket_address": { + "address": "192.168.79.187", + "port_value": 8502 + } + }, + "stats": [ + { + "value": "8", + "name": "cx_connect_fail" + }, + { + "value": "11", + "name": "cx_total" + }, + { + "value": "10", + "name": "rq_error" + }, + { + "name": "rq_success" + }, + { + "name": "rq_timeout" + }, + { + "value": "3", + "name": "rq_total" + }, + { + "type": "GAUGE", + "value": "1", + "name": "cx_active" + }, + { + "type": "GAUGE", + "value": "1", + "name": "rq_active" + } + ], + "health_status": { + "eds_health_status": "HEALTHY" + }, + "weight": 1, + "locality": {} } - ] + ], + "circuit_breakers": { + "thresholds": [ + { + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + }, + { + "priority": "HIGH", + "max_connections": 1024, + "max_pending_requests": 1024, + "max_requests": 1024, + "max_retries": 3 + } + ] + }, + "observability_name": "local_agent" + } + ] } diff --git a/cli/cmd/proxy/read/test_config_dump.json b/cli/cmd/proxy/read/test_config_dump.json index 982f50483d..e66e0e325a 100644 --- a/cli/cmd/proxy/read/test_config_dump.json +++ b/cli/cmd/proxy/read/test_config_dump.json @@ -7,8 +7,8 @@ "id": "backend-658b679b45-d5xlb-backend-sidecar-proxy", "cluster": "backend", "metadata": { - "partition": "default", - "namespace": "default" + "namespace": "default", + "partition": "default" }, "user_agent_name": "envoy", "user_agent_build_version": { @@ -17,10 +17,10 @@ "minor_number": 22 }, "metadata": { - "revision.status": "Clean", "ssl.version": "BoringSSL", - "revision.sha": "dcd329a2e95b54f754b17aceca3f72724294b502", - "build.type": "RELEASE" + "revision.status": "Clean", + "build.type": "RELEASE", + "revision.sha": "dcd329a2e95b54f754b17aceca3f72724294b502" } }, "extensions": [ @@ -1255,7 +1255,7 @@ ], "dynamic_active_clusters": [ { - "version_info": "877646fa9c433fbe25febc99b0725a44ab606d9f5407b76a6b7513edd1ac8af2", + "version_info": "2eee24224b508d5e77766867b5ad793bc4555abce4d3fa564da125617c68e46a", "cluster": { "@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster", "name": "client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", @@ -1278,7 +1278,7 @@ "tls_certificates": [ { "certificate_chain": { - "inline_string": "-----BEGIN CERTIFICATE-----\nMIICHDCCAcGgAwIBAgIBWDAKBggqhkjOPQQDAjAxMS8wLQYDVQQDEyZwcmktNDl4\ncnFxejQuY29uc3VsLmNhLmJjMzgxNWMyLmNvbnN1bDAeFw0yMjA2MDkwMDM4MTJa\nFw0yMjA2MTIwMDM4MTJaMAAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARGkJfg\n3Hy48dvsqnsJ7Xmb00ZGzNaGl89++zg3PgppbvXiU+u3oK7qON/pQ3hinsjXnubr\n2y5RRaKjRke+HyTBo4H6MIH3MA4GA1UdDwEB/wQEAwIDuDAdBgNVHSUEFjAUBggr\nBgEFBQcDAgYIKwYBBQUHAwEwDAYDVR0TAQH/BAIwADApBgNVHQ4EIgQgJK3rY8+n\n0pg4r+1+uIsBl2YqMXGTQdZ45yR8lDILXtEwKwYDVR0jBCQwIoAg1Fr3vJvXDnVW\nt0yAoYFvX8S/Kehuir9zvx8uM1UIaIkwYAYDVR0RAQH/BFYwVIZSc3BpZmZlOi8v\nYmMzODE1YzItMWEwZi1mM2ZmLWEyZTktMjBkNzkxZjA4ZDAwLmNvbnN1bC9ucy9k\nZWZhdWx0L2RjL2RjMS9zdmMvYmFja2VuZDAKBggqhkjOPQQDAgNJADBGAiEAlik6\nBgXf8zAT3cV+ZDEz9d1oApzde8+HLoadXrDimzICIQCCDk3QL/rK5jTv6p0iqkY1\nqUPq56zIQeZ7SHUZe8Wm0A==\n-----END CERTIFICATE-----\n" + "inline_string": "-----BEGIN CERTIFICATE-----\nMIICGzCCAcKgAwIBAgICATgwCgYIKoZIzj0EAwIwMTEvMC0GA1UEAxMmcHJpLTQ5\neHJxcXo0LmNvbnN1bC5jYS5iYzM4MTVjMi5jb25zdWwwHhcNMjIwODEwMTIyOTMx\nWhcNMjIwODEzMTIyOTMxWjAAMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEwIK1\nchHdnpY6/q384TYjGoNhuB+rZI0dMYDjc6Zlb6i0wIKDXtGF4mu6pGBZLkTg0Jmi\nWRysYZG0xZXJ3CCCZqOB+jCB9zAOBgNVHQ8BAf8EBAMCA7gwHQYDVR0lBBYwFAYI\nKwYBBQUHAwIGCCsGAQUFBwMBMAwGA1UdEwEB/wQCMAAwKQYDVR0OBCIEIIz1546B\nHMv70/ecIGSXuy/0UFErFDl+x6rL2H5Q1HuCMCsGA1UdIwQkMCKAINRa97yb1w51\nVrdMgKGBb1/Evynoboq/c78fLjNVCGiJMGAGA1UdEQEB/wRWMFSGUnNwaWZmZTov\nL2JjMzgxNWMyLTFhMGYtZjNmZi1hMmU5LTIwZDc5MWYwOGQwMC5jb25zdWwvbnMv\nZGVmYXVsdC9kYy9kYzEvc3ZjL2JhY2tlbmQwCgYIKoZIzj0EAwIDRwAwRAIgGAkg\n9NJtR/hMkaBS7cTEn5aoQ6NcmsKdAy7UXHysdkcCIFas15UPc5cSjjpNie/UnFde\nH0bDhbYMCKTZVGj3hvhr\n-----END CERTIFICATE-----\n" }, "private_key": { "inline_string": "[redacted]" @@ -1304,10 +1304,10 @@ }, "alt_stat_name": "client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul" }, - "last_updated": "2022-06-09T00:39:12.948Z" + "last_updated": "2022-08-10T12:30:32.326Z" }, { - "version_info": "e0cc5c279829d13f01d2ba3a4d32546c0d3fc65b930bbb0bf66a68ad76e152a0", + "version_info": "70b55eac9f1c87dfb54a56d1624279740ddaa2ab72ce7f0baf024b089c396acc", "cluster": { "@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster", "name": "frontend.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", @@ -1330,7 +1330,7 @@ "tls_certificates": [ { "certificate_chain": { - "inline_string": "-----BEGIN CERTIFICATE-----\nMIICHDCCAcGgAwIBAgIBWDAKBggqhkjOPQQDAjAxMS8wLQYDVQQDEyZwcmktNDl4\ncnFxejQuY29uc3VsLmNhLmJjMzgxNWMyLmNvbnN1bDAeFw0yMjA2MDkwMDM4MTJa\nFw0yMjA2MTIwMDM4MTJaMAAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARGkJfg\n3Hy48dvsqnsJ7Xmb00ZGzNaGl89++zg3PgppbvXiU+u3oK7qON/pQ3hinsjXnubr\n2y5RRaKjRke+HyTBo4H6MIH3MA4GA1UdDwEB/wQEAwIDuDAdBgNVHSUEFjAUBggr\nBgEFBQcDAgYIKwYBBQUHAwEwDAYDVR0TAQH/BAIwADApBgNVHQ4EIgQgJK3rY8+n\n0pg4r+1+uIsBl2YqMXGTQdZ45yR8lDILXtEwKwYDVR0jBCQwIoAg1Fr3vJvXDnVW\nt0yAoYFvX8S/Kehuir9zvx8uM1UIaIkwYAYDVR0RAQH/BFYwVIZSc3BpZmZlOi8v\nYmMzODE1YzItMWEwZi1mM2ZmLWEyZTktMjBkNzkxZjA4ZDAwLmNvbnN1bC9ucy9k\nZWZhdWx0L2RjL2RjMS9zdmMvYmFja2VuZDAKBggqhkjOPQQDAgNJADBGAiEAlik6\nBgXf8zAT3cV+ZDEz9d1oApzde8+HLoadXrDimzICIQCCDk3QL/rK5jTv6p0iqkY1\nqUPq56zIQeZ7SHUZe8Wm0A==\n-----END CERTIFICATE-----\n" + "inline_string": "-----BEGIN CERTIFICATE-----\nMIICGzCCAcKgAwIBAgICATgwCgYIKoZIzj0EAwIwMTEvMC0GA1UEAxMmcHJpLTQ5\neHJxcXo0LmNvbnN1bC5jYS5iYzM4MTVjMi5jb25zdWwwHhcNMjIwODEwMTIyOTMx\nWhcNMjIwODEzMTIyOTMxWjAAMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEwIK1\nchHdnpY6/q384TYjGoNhuB+rZI0dMYDjc6Zlb6i0wIKDXtGF4mu6pGBZLkTg0Jmi\nWRysYZG0xZXJ3CCCZqOB+jCB9zAOBgNVHQ8BAf8EBAMCA7gwHQYDVR0lBBYwFAYI\nKwYBBQUHAwIGCCsGAQUFBwMBMAwGA1UdEwEB/wQCMAAwKQYDVR0OBCIEIIz1546B\nHMv70/ecIGSXuy/0UFErFDl+x6rL2H5Q1HuCMCsGA1UdIwQkMCKAINRa97yb1w51\nVrdMgKGBb1/Evynoboq/c78fLjNVCGiJMGAGA1UdEQEB/wRWMFSGUnNwaWZmZTov\nL2JjMzgxNWMyLTFhMGYtZjNmZi1hMmU5LTIwZDc5MWYwOGQwMC5jb25zdWwvbnMv\nZGVmYXVsdC9kYy9kYzEvc3ZjL2JhY2tlbmQwCgYIKoZIzj0EAwIDRwAwRAIgGAkg\n9NJtR/hMkaBS7cTEn5aoQ6NcmsKdAy7UXHysdkcCIFas15UPc5cSjjpNie/UnFde\nH0bDhbYMCKTZVGj3hvhr\n-----END CERTIFICATE-----\n" }, "private_key": { "inline_string": "[redacted]" @@ -1356,7 +1356,7 @@ }, "alt_stat_name": "frontend.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul" }, - "last_updated": "2022-06-09T00:39:12.855Z" + "last_updated": "2022-08-10T12:30:32.233Z" }, { "version_info": "642b6322013fd3f776d9644ece515db5c4901fe6a87575ab4ff07498ab5faa47", @@ -1397,58 +1397,6 @@ "lb_policy": "CLUSTER_PROVIDED" }, "last_updated": "2022-05-13T04:22:39.743Z" - }, - { - "version_info": "1454ffe616e7abd2b3bec548b88f3a14c0500a94de27f2b3e8e3913e7bfd3275", - "cluster": { - "@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster", - "name": "server.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", - "type": "EDS", - "eds_cluster_config": { - "eds_config": { - "ads": {}, - "resource_api_version": "V3" - } - }, - "connect_timeout": "5s", - "circuit_breakers": {}, - "outlier_detection": {}, - "transport_socket": { - "name": "tls", - "typed_config": { - "@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext", - "common_tls_context": { - "tls_params": {}, - "tls_certificates": [ - { - "certificate_chain": { - "inline_string": "-----BEGIN CERTIFICATE-----\nMIICHDCCAcGgAwIBAgIBWDAKBggqhkjOPQQDAjAxMS8wLQYDVQQDEyZwcmktNDl4\ncnFxejQuY29uc3VsLmNhLmJjMzgxNWMyLmNvbnN1bDAeFw0yMjA2MDkwMDM4MTJa\nFw0yMjA2MTIwMDM4MTJaMAAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARGkJfg\n3Hy48dvsqnsJ7Xmb00ZGzNaGl89++zg3PgppbvXiU+u3oK7qON/pQ3hinsjXnubr\n2y5RRaKjRke+HyTBo4H6MIH3MA4GA1UdDwEB/wQEAwIDuDAdBgNVHSUEFjAUBggr\nBgEFBQcDAgYIKwYBBQUHAwEwDAYDVR0TAQH/BAIwADApBgNVHQ4EIgQgJK3rY8+n\n0pg4r+1+uIsBl2YqMXGTQdZ45yR8lDILXtEwKwYDVR0jBCQwIoAg1Fr3vJvXDnVW\nt0yAoYFvX8S/Kehuir9zvx8uM1UIaIkwYAYDVR0RAQH/BFYwVIZSc3BpZmZlOi8v\nYmMzODE1YzItMWEwZi1mM2ZmLWEyZTktMjBkNzkxZjA4ZDAwLmNvbnN1bC9ucy9k\nZWZhdWx0L2RjL2RjMS9zdmMvYmFja2VuZDAKBggqhkjOPQQDAgNJADBGAiEAlik6\nBgXf8zAT3cV+ZDEz9d1oApzde8+HLoadXrDimzICIQCCDk3QL/rK5jTv6p0iqkY1\nqUPq56zIQeZ7SHUZe8Wm0A==\n-----END CERTIFICATE-----\n" - }, - "private_key": { - "inline_string": "[redacted]" - } - } - ], - "validation_context": { - "trusted_ca": { - "inline_string": "-----BEGIN CERTIFICATE-----\nMIICEDCCAbWgAwIBAgIBBzAKBggqhkjOPQQDAjAxMS8wLQYDVQQDEyZwcmktNDl4\ncnFxejQuY29uc3VsLmNhLmJjMzgxNWMyLmNvbnN1bDAeFw0yMjA1MTMwNDE4MDBa\nFw0zMjA1MTAwNDE4MDBaMDExLzAtBgNVBAMTJnByaS00OXhycXF6NC5jb25zdWwu\nY2EuYmMzODE1YzIuY29uc3VsMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEwQHp\nkEZUr0LVB1ng/zQMQyEQnID/wN/0+Ve648F3Lz4+S7D/S41EQ1Q9ImrNGIlmJ1b2\ncL9WcsL1A1/Ts8xNSaOBvTCBujAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUw\nAwEB/zApBgNVHQ4EIgQg1Fr3vJvXDnVWt0yAoYFvX8S/Kehuir9zvx8uM1UIaIkw\nKwYDVR0jBCQwIoAg1Fr3vJvXDnVWt0yAoYFvX8S/Kehuir9zvx8uM1UIaIkwPwYD\nVR0RBDgwNoY0c3BpZmZlOi8vYmMzODE1YzItMWEwZi1mM2ZmLWEyZTktMjBkNzkx\nZjA4ZDAwLmNvbnN1bDAKBggqhkjOPQQDAgNJADBGAiEAhxIMzmCZT1sjtEKsjHIM\nC//yOo+pXZ62GQk+7rsE9HoCIQCxdLmYFUvOOiIXt4S15tvBpuJ6PdrKNlRTbmLx\nA5z5lQ==\n-----END CERTIFICATE-----\n" - }, - "match_subject_alt_names": [ - { - "exact": "spiffe://bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul/ns/default/dc/dc1/svc/server" - } - ] - } - }, - "sni": "server.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul" - } - }, - "common_lb_config": { - "healthy_panic_threshold": {} - }, - "alt_stat_name": "server.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul" - }, - "last_updated": "2022-06-09T00:39:12.754Z" } ] }, @@ -1486,35 +1434,6 @@ } ], "dynamic_endpoint_configs": [ - { - "endpoint_config": { - "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", - "cluster_name": "local_app", - "endpoints": [ - { - "locality": {}, - "lb_endpoints": [ - { - "endpoint": { - "address": { - "socket_address": { - "address": "127.0.0.1", - "port_value": 8080 - } - }, - "health_check_config": {} - }, - "health_status": "HEALTHY", - "load_balancing_weight": 1 - } - ] - } - ], - "policy": { - "overprovisioning_factor": 140 - } - } - }, { "endpoint_config": { "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", @@ -1526,7 +1445,7 @@ "endpoint": { "address": { "socket_address": { - "address": "192.168.31.201", + "address": "192.168.18.110", "port_value": 20000 } }, @@ -1539,7 +1458,7 @@ "endpoint": { "address": { "socket_address": { - "address": "192.168.47.235", + "address": "192.168.52.101", "port_value": 20000 } }, @@ -1552,7 +1471,7 @@ "endpoint": { "address": { "socket_address": { - "address": "192.168.71.254", + "address": "192.168.65.131", "port_value": 20000 } }, @@ -1600,6 +1519,16 @@ { "endpoint_config": { "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", + "cluster_name": "original-destination", + "policy": { + "overprovisioning_factor": 140 + } + } + }, + { + "endpoint_config": { + "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", + "cluster_name": "local_app", "endpoints": [ { "locality": {}, @@ -1608,34 +1537,8 @@ "endpoint": { "address": { "socket_address": { - "address": "192.168.18.110", - "port_value": 20000 - } - }, - "health_check_config": {} - }, - "health_status": "HEALTHY", - "load_balancing_weight": 1 - }, - { - "endpoint": { - "address": { - "socket_address": { - "address": "192.168.52.101", - "port_value": 20000 - } - }, - "health_check_config": {} - }, - "health_status": "HEALTHY", - "load_balancing_weight": 1 - }, - { - "endpoint": { - "address": { - "socket_address": { - "address": "192.168.65.131", - "port_value": 20000 + "address": "127.0.0.1", + "port_value": 8080 } }, "health_check_config": {} @@ -1650,15 +1553,6 @@ "overprovisioning_factor": 140 } } - }, - { - "endpoint_config": { - "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", - "cluster_name": "original-destination", - "policy": { - "overprovisioning_factor": 140 - } - } } ] }, @@ -1729,6 +1623,16 @@ } } } + }, + { + "authenticated": { + "principal_name": { + "safe_regex": { + "google_re2": {}, + "regex": "^spiffe://[^/]+/ns/default/dc/[^/]+/svc/ingress-gateway$" + } + } + } } ] } @@ -1758,7 +1662,7 @@ "tls_certificates": [ { "certificate_chain": { - "inline_string": "-----BEGIN CERTIFICATE-----\nMIICHDCCAcGgAwIBAgIBWDAKBggqhkjOPQQDAjAxMS8wLQYDVQQDEyZwcmktNDl4\ncnFxejQuY29uc3VsLmNhLmJjMzgxNWMyLmNvbnN1bDAeFw0yMjA2MDkwMDM4MTJa\nFw0yMjA2MTIwMDM4MTJaMAAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARGkJfg\n3Hy48dvsqnsJ7Xmb00ZGzNaGl89++zg3PgppbvXiU+u3oK7qON/pQ3hinsjXnubr\n2y5RRaKjRke+HyTBo4H6MIH3MA4GA1UdDwEB/wQEAwIDuDAdBgNVHSUEFjAUBggr\nBgEFBQcDAgYIKwYBBQUHAwEwDAYDVR0TAQH/BAIwADApBgNVHQ4EIgQgJK3rY8+n\n0pg4r+1+uIsBl2YqMXGTQdZ45yR8lDILXtEwKwYDVR0jBCQwIoAg1Fr3vJvXDnVW\nt0yAoYFvX8S/Kehuir9zvx8uM1UIaIkwYAYDVR0RAQH/BFYwVIZSc3BpZmZlOi8v\nYmMzODE1YzItMWEwZi1mM2ZmLWEyZTktMjBkNzkxZjA4ZDAwLmNvbnN1bC9ucy9k\nZWZhdWx0L2RjL2RjMS9zdmMvYmFja2VuZDAKBggqhkjOPQQDAgNJADBGAiEAlik6\nBgXf8zAT3cV+ZDEz9d1oApzde8+HLoadXrDimzICIQCCDk3QL/rK5jTv6p0iqkY1\nqUPq56zIQeZ7SHUZe8Wm0A==\n-----END CERTIFICATE-----\n" + "inline_string": "-----BEGIN CERTIFICATE-----\nMIICGzCCAcKgAwIBAgICATgwCgYIKoZIzj0EAwIwMTEvMC0GA1UEAxMmcHJpLTQ5\neHJxcXo0LmNvbnN1bC5jYS5iYzM4MTVjMi5jb25zdWwwHhcNMjIwODEwMTIyOTMx\nWhcNMjIwODEzMTIyOTMxWjAAMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEwIK1\nchHdnpY6/q384TYjGoNhuB+rZI0dMYDjc6Zlb6i0wIKDXtGF4mu6pGBZLkTg0Jmi\nWRysYZG0xZXJ3CCCZqOB+jCB9zAOBgNVHQ8BAf8EBAMCA7gwHQYDVR0lBBYwFAYI\nKwYBBQUHAwIGCCsGAQUFBwMBMAwGA1UdEwEB/wQCMAAwKQYDVR0OBCIEIIz1546B\nHMv70/ecIGSXuy/0UFErFDl+x6rL2H5Q1HuCMCsGA1UdIwQkMCKAINRa97yb1w51\nVrdMgKGBb1/Evynoboq/c78fLjNVCGiJMGAGA1UdEQEB/wRWMFSGUnNwaWZmZTov\nL2JjMzgxNWMyLTFhMGYtZjNmZi1hMmU5LTIwZDc5MWYwOGQwMC5jb25zdWwvbnMv\nZGVmYXVsdC9kYy9kYzEvc3ZjL2JhY2tlbmQwCgYIKoZIzj0EAwIDRwAwRAIgGAkg\n9NJtR/hMkaBS7cTEn5aoQ6NcmsKdAy7UXHysdkcCIFas15UPc5cSjjpNie/UnFde\nH0bDhbYMCKTZVGj3hvhr\n-----END CERTIFICATE-----\n" }, "private_key": { "inline_string": "[redacted]" @@ -1778,7 +1682,7 @@ ], "traffic_direction": "INBOUND" }, - "last_updated": "2022-06-09T00:39:27.668Z" + "last_updated": "2022-08-10T12:30:47.142Z" } }, { @@ -1819,59 +1723,6 @@ } ] }, - { - "filter_chain_match": { - "prefix_ranges": [ - { - "address_prefix": "10.100.254.176", - "prefix_len": 32 - }, - { - "address_prefix": "240.0.0.4", - "prefix_len": 32 - } - ] - }, - "filters": [ - { - "name": "envoy.filters.network.http_connection_manager", - "typed_config": { - "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager", - "stat_prefix": "upstream.server.default.default.dc1", - "route_config": { - "name": "server", - "virtual_hosts": [ - { - "name": "server.default.default.dc1", - "domains": ["*"], - "routes": [ - { - "match": { - "prefix": "/" - }, - "route": { - "cluster": "server.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul" - } - } - ] - } - ] - }, - "http_filters": [ - { - "name": "envoy.filters.http.router", - "typed_config": { - "@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router" - } - } - ], - "tracing": { - "random_sampling": {} - } - } - } - ] - }, { "filter_chain_match": { "prefix_ranges": [ @@ -1880,7 +1731,7 @@ "prefix_len": 32 }, { - "address_prefix": "240.0.0.2", + "address_prefix": "240.0.0.5", "prefix_len": 32 } ] @@ -1919,7 +1770,7 @@ ], "traffic_direction": "OUTBOUND" }, - "last_updated": "2022-05-24T17:41:59.079Z" + "last_updated": "2022-07-18T15:31:03.246Z" } } ] @@ -1951,30 +1802,7 @@ } ] }, - "last_updated": "2022-06-09T00:39:27.667Z" - }, - { - "route_config": { - "@type": "type.googleapis.com/envoy.config.route.v3.RouteConfiguration", - "name": "server", - "virtual_hosts": [ - { - "name": "server.default.default.dc1", - "domains": ["*"], - "routes": [ - { - "match": { - "prefix": "/" - }, - "route": { - "cluster": "server.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul" - } - } - ] - } - ] - }, - "last_updated": "2022-05-24T17:41:59.078Z" + "last_updated": "2022-08-10T12:30:47.141Z" } ] }, From 7d4dd0dfa4649438c94fa150fce0c66518751943 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Aug 2022 17:18:36 -0400 Subject: [PATCH 04/13] Add a warning if field filter and table filter combo is wacky --- cli/cmd/proxy/read/command.go | 32 +++++++++++++++++++++++++++ cli/cmd/proxy/read/command_test.go | 35 ++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/cli/cmd/proxy/read/command.go b/cli/cmd/proxy/read/command.go index 31e1d20892..235a17f4a5 100644 --- a/cli/cmd/proxy/read/command.go +++ b/cli/cmd/proxy/read/command.go @@ -327,6 +327,34 @@ func (c *ReadCommand) shouldPrintTable(table bool) bool { return !(c.flagClusters || c.flagEndpoints || c.flagListeners || c.flagRoutes || c.flagSecrets) } +// filterWarnings checks if the user has passed in a combination of field and +// table filters where the field in question is not present on the table and +// returns a warning. +// For example, if the user passes "-fqdn default -endpoints", a warning will +// be printed saying "The filter `-fqdn default` does not apply to the tables displayed.". +func (c *ReadCommand) filterWarnings() []string { + var warnings []string + + // No table filters passed. Return early. + if !(c.flagClusters || c.flagEndpoints || c.flagListeners || c.flagRoutes || c.flagSecrets) { + return warnings + } + + if c.flagFQDN != "" && !c.flagClusters { + warnings = append(warnings, fmt.Sprintf("The filter `-fqdn %s` does not apply to the tables displayed.", c.flagFQDN)) + } + + if c.flagPort != -1 && !(c.flagClusters || c.flagEndpoints || c.flagListeners) { + warnings = append(warnings, fmt.Sprintf("The filter `-port %d` does not apply to the tables displayed.", c.flagPort)) + } + + if c.flagAddress != "" && !(c.flagClusters || c.flagEndpoints || c.flagListeners) { + warnings = append(warnings, fmt.Sprintf("The filter `-address %s` does not apply to the tables displayed.", c.flagAddress)) + } + + return warnings +} + func (c *ReadCommand) outputTables(configs map[string]*EnvoyConfig) error { if c.flagFQDN != "" || c.flagAddress != "" || c.flagPort != -1 { c.UI.Output("Filters applied", terminal.WithHeaderStyle()) @@ -341,6 +369,10 @@ func (c *ReadCommand) outputTables(configs map[string]*EnvoyConfig) error { c.UI.Output(fmt.Sprintf("Endpoint addresses with port number: %d", c.flagPort), terminal.WithInfoStyle()) } + for _, warning := range c.filterWarnings() { + c.UI.Output(warning, terminal.WithWarningStyle()) + } + c.UI.Output("") } diff --git a/cli/cmd/proxy/read/command_test.go b/cli/cmd/proxy/read/command_test.go index be9e226bb4..b59c693cef 100644 --- a/cli/cmd/proxy/read/command_test.go +++ b/cli/cmd/proxy/read/command_test.go @@ -140,6 +140,41 @@ func TestReadCommandOutput(t *testing.T) { } } +// TestFilterWarnings ensures that a warning is printed if the user applies a +// field filter (e.g. -fqdn default) and a table filter (e.g. -secrets) where +// the former does not affect the output of the latter. +func TestFilterWarnings(t *testing.T) { + podName := "fakePod" + cases := map[string][]string{ + "fully qualified domain name doesn't apply to secrets": {"-fqdn", "default", "-secrets"}, + "port doesn't apply to secrets or routes": {"-port", "8080", "-secrets", "-routes"}, + "fully qualified domain name doesn't apply to endpoints or listeners": {"-fqdn", "default", "-endpoints", "-listeners"}, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + fakePod := v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: podName, + Namespace: "default", + }, + } + + buf := new(bytes.Buffer) + c := setupCommand(buf) + c.kubernetes = fake.NewSimpleClientset(&v1.PodList{Items: []v1.Pod{fakePod}}) + c.fetchConfig = func(context.Context, common.PortForwarder) (*EnvoyConfig, error) { + return testEnvoyConfig, nil + } + + out := c.Run(append([]string{podName}, tc...)) + require.Equal(t, 0, out) // This shouldn't error out, just warn the user. + + require.Regexp(t, "The filter.*does not apply to the tables displayed.", buf.String()) + }) + } +} + func setupCommand(buf io.Writer) *ReadCommand { // Log at a test level to standard out. log := hclog.New(&hclog.LoggerOptions{ From d8f181cc9d8395d3b5353bb270ce9e1d17f5627e Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Aug 2022 17:26:43 -0400 Subject: [PATCH 05/13] Fix linting issue --- cli/cmd/proxy/list/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cmd/proxy/list/command.go b/cli/cmd/proxy/list/command.go index ee29864728..385ba3f41b 100644 --- a/cli/cmd/proxy/list/command.go +++ b/cli/cmd/proxy/list/command.go @@ -128,7 +128,7 @@ func (c *ListCommand) validateFlags() error { return nil } -// initKubernetes initializes the Kubernetes client +// initKubernetes initializes the Kubernetes client. func (c *ListCommand) initKubernetes() error { settings := helmCLI.New() From 3f4f72ebe5b86459d12e399ab9ca5a6089b32697 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Aug 2022 20:21:26 -0400 Subject: [PATCH 06/13] Re-add newline in list command --- cli/cmd/proxy/list/command.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/cmd/proxy/list/command.go b/cli/cmd/proxy/list/command.go index 385ba3f41b..d1b5f0eb93 100644 --- a/cli/cmd/proxy/list/command.go +++ b/cli/cmd/proxy/list/command.go @@ -209,9 +209,9 @@ func (c *ListCommand) output(pods []v1.Pod) { } if c.flagAllNamespaces { - c.UI.Output("Namespace: all namespaces") + c.UI.Output("Namespace: all namespaces\n") } else { - c.UI.Output("Namespace: %s", c.namespace()) + c.UI.Output("Namespace: %s\n", c.namespace()) } var tbl *terminal.Table From 85d40ee2c4f5c02cda4f00fcebf03897aa45a45c Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Tue, 16 Aug 2022 16:06:27 -0400 Subject: [PATCH 07/13] Return nil from initKubernetes --- cli/cmd/proxy/list/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cmd/proxy/list/command.go b/cli/cmd/proxy/list/command.go index d1b5f0eb93..780a376a0f 100644 --- a/cli/cmd/proxy/list/command.go +++ b/cli/cmd/proxy/list/command.go @@ -148,7 +148,7 @@ func (c *ListCommand) initKubernetes() error { return fmt.Errorf("error creating Kubernetes client %v", err) } - return err + return nil } func (c *ListCommand) namespace() string { From 134acb58f20214dbb90b9398f430facfdb39d12d Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Wed, 17 Aug 2022 10:01:34 -0400 Subject: [PATCH 08/13] Change out to exitCode Co-authored-by: Iryna Shustava --- cli/cmd/proxy/list/command_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cmd/proxy/list/command_test.go b/cli/cmd/proxy/list/command_test.go index 34c776cd2a..4af5dee20d 100644 --- a/cli/cmd/proxy/list/command_test.go +++ b/cli/cmd/proxy/list/command_test.go @@ -332,7 +332,7 @@ func TestNoPodsFound(t *testing.T) { c := setupCommand(buf) c.kubernetes = fake.NewSimpleClientset() - out := c.Run(tc.args) + exitCode := c.Run(tc.args) require.Equal(t, 0, out) require.Regexp(t, tc.expected, buf.String()) From fbc7c1816c48120c2f45926c174b2ed3a12fe9e0 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Wed, 17 Aug 2022 10:04:55 -0400 Subject: [PATCH 09/13] Use contains instead of regex --- cli/cmd/proxy/list/command_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/cmd/proxy/list/command_test.go b/cli/cmd/proxy/list/command_test.go index 4af5dee20d..a29c851391 100644 --- a/cli/cmd/proxy/list/command_test.go +++ b/cli/cmd/proxy/list/command_test.go @@ -333,9 +333,9 @@ func TestNoPodsFound(t *testing.T) { c.kubernetes = fake.NewSimpleClientset() exitCode := c.Run(tc.args) - require.Equal(t, 0, out) + require.Equal(t, 0, exitCode) - require.Regexp(t, tc.expected, buf.String()) + require.Contains(t, buf.String(), tc.expected) }) } } From db9a5b022e22988ed06277c7e8a7b3bdd13da32b Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Wed, 17 Aug 2022 10:17:23 -0400 Subject: [PATCH 10/13] Include FQDNs without periods as FQDNs --- cli/cmd/proxy/read/config.go | 8 +------- cli/cmd/proxy/read/config_test.go | 6 +++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cli/cmd/proxy/read/config.go b/cli/cmd/proxy/read/config.go index 38b8651d5e..a3ec904146 100644 --- a/cli/cmd/proxy/read/config.go +++ b/cli/cmd/proxy/read/config.go @@ -219,15 +219,9 @@ func parseClusters(rawCfg map[string]interface{}, clusterMapping map[string][]st } } - // Don't display "non-domain name" FQDNs (e.g. local_app) - fqdn := cluster.Cluster.FQDN - if !strings.Contains(fqdn, ".") { - fqdn = "" - } - clusters = append(clusters, Cluster{ Name: strings.Split(cluster.Cluster.FQDN, ".")[0], - FullyQualifiedDomainName: fqdn, + FullyQualifiedDomainName: cluster.Cluster.FQDN, Endpoints: endpoints, Type: cluster.Cluster.ClusterType, LastUpdated: cluster.LastUpdated, diff --git a/cli/cmd/proxy/read/config_test.go b/cli/cmd/proxy/read/config_test.go index 33a90b01c9..a32451a3c2 100644 --- a/cli/cmd/proxy/read/config_test.go +++ b/cli/cmd/proxy/read/config_test.go @@ -102,11 +102,11 @@ func rawEnvoyConfig(t *testing.T) []byte { // testEnvoyConfig is what we expect the config at `test_config_dump.json` to be. var testEnvoyConfig = &EnvoyConfig{ Clusters: []Cluster{ - {Name: "local_agent", Endpoints: []string{"192.168.79.187:8502"}, Type: "STATIC", LastUpdated: "2022-05-13T04:22:39.553Z"}, + {Name: "local_agent", FullyQualifiedDomainName: "local_agent", Endpoints: []string{"192.168.79.187:8502"}, Type: "STATIC", LastUpdated: "2022-05-13T04:22:39.553Z"}, {Name: "client", FullyQualifiedDomainName: "client.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", Endpoints: []string{"192.168.18.110:20000", "192.168.52.101:20000", "192.168.65.131:20000"}, Type: "EDS", LastUpdated: "2022-08-10T12:30:32.326Z"}, {Name: "frontend", FullyQualifiedDomainName: "frontend.default.dc1.internal.bc3815c2-1a0f-f3ff-a2e9-20d791f08d00.consul", Endpoints: []string{"192.168.63.120:20000"}, Type: "EDS", LastUpdated: "2022-08-10T12:30:32.233Z"}, - {Name: "local_app", Endpoints: []string{"127.0.0.1:8080"}, Type: "STATIC", LastUpdated: "2022-05-13T04:22:39.655Z"}, - {Name: "original-destination", Endpoints: []string{}, Type: "ORIGINAL_DST", LastUpdated: "2022-05-13T04:22:39.743Z"}, + {Name: "local_app", FullyQualifiedDomainName: "local_app", Endpoints: []string{"127.0.0.1:8080"}, Type: "STATIC", LastUpdated: "2022-05-13T04:22:39.655Z"}, + {Name: "original-destination", FullyQualifiedDomainName: "original-destination", Endpoints: []string{}, Type: "ORIGINAL_DST", LastUpdated: "2022-05-13T04:22:39.743Z"}, }, Endpoints: []Endpoint{ {Address: "192.168.79.187:8502", Cluster: "local_agent", Weight: 1, Status: "HEALTHY"}, From e3d48ffde1b20b696666d5df0bedea8942f78acc Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 18 Aug 2022 10:19:20 -0400 Subject: [PATCH 11/13] Expand the filtering tests --- cli/cmd/proxy/read/command_test.go | 70 +++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/cli/cmd/proxy/read/command_test.go b/cli/cmd/proxy/read/command_test.go index b59c693cef..6cc3cfcf98 100644 --- a/cli/cmd/proxy/read/command_test.go +++ b/cli/cmd/proxy/read/command_test.go @@ -145,10 +145,62 @@ func TestReadCommandOutput(t *testing.T) { // the former does not affect the output of the latter. func TestFilterWarnings(t *testing.T) { podName := "fakePod" - cases := map[string][]string{ - "fully qualified domain name doesn't apply to secrets": {"-fqdn", "default", "-secrets"}, - "port doesn't apply to secrets or routes": {"-port", "8080", "-secrets", "-routes"}, - "fully qualified domain name doesn't apply to endpoints or listeners": {"-fqdn", "default", "-endpoints", "-listeners"}, + cases := map[string]struct { + input []string + shouldWarn bool + }{ + "fully qualified domain name doesn't apply to listeners": { + input: []string{"-fqdn", "default", "-listeners"}, + shouldWarn: true, + }, + "fully qualified domain name doesn't apply to routes": { + input: []string{"-fqdn", "default", "-routes"}, + shouldWarn: true, + }, + "fully qualified domain name doesn't apply to endpoints": { + input: []string{"-fqdn", "default", "-endpoints"}, + shouldWarn: true, + }, + "fully qualified domain name doesn't apply to secrets": { + input: []string{"-fqdn", "default", "-secrets"}, + shouldWarn: true, + }, + "fully qualified domain name doesn't apply to endpoints or listeners": { + input: []string{"-fqdn", "default", "-endpoints", "-listeners"}, + shouldWarn: true, + }, + "fully qualified domain name doesn't apply to listeners, routes, endpoints, or secrets": { + input: []string{"-fqdn", "default", "-listeners", "-routes", "-endpoints", "-secrets"}, + shouldWarn: true, + }, + "port doesn't apply to routes": { + input: []string{"-port", "8080", "-routes"}, + shouldWarn: true, + }, + "port doesn't apply to secrets": { + input: []string{"-port", "8080", "-secrets"}, + shouldWarn: true, + }, + "port doesn't apply to secrets or routes": { + input: []string{"-port", "8080", "-secrets", "-routes"}, + shouldWarn: true, + }, + "address does not apply to routes": { + input: []string{"-address", "127.0.0.1", "-routes"}, + shouldWarn: true, + }, + "address does not apply to secrets": { + input: []string{"-address", "127.0.0.1", "-secrets"}, + shouldWarn: true, + }, + "multiple warnings": { + input: []string{"-address", "127.0.0.1", "-port", "8080", "-secrets"}, + shouldWarn: true, + }, + "no warning produced (happy case)": { + input: []string{"-fqdn", "default", "-clusters"}, + shouldWarn: false, + }, } for name, tc := range cases { @@ -167,10 +219,14 @@ func TestFilterWarnings(t *testing.T) { return testEnvoyConfig, nil } - out := c.Run(append([]string{podName}, tc...)) - require.Equal(t, 0, out) // This shouldn't error out, just warn the user. + exitCode := c.Run(append([]string{podName}, tc.input...)) + require.Equal(t, 0, exitCode) // This shouldn't error out, just warn the user. - require.Regexp(t, "The filter.*does not apply to the tables displayed.", buf.String()) + if tc.shouldWarn { + require.Regexp(t, "The filter.*does not apply to the tables displayed.", buf.String()) + } else { + require.NotRegexp(t, "The filter.*does not apply to the tables displayed.", buf.String()) + } }) } } From cba25f5487664f8ee98de12e1ae1c285d9525f8f Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Mon, 22 Aug 2022 10:57:17 -0400 Subject: [PATCH 12/13] Test multiple warnings properly --- cli/cmd/proxy/read/command_test.go | 75 +++++++++++++++++------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/cli/cmd/proxy/read/command_test.go b/cli/cmd/proxy/read/command_test.go index 6cc3cfcf98..48f5aab6a2 100644 --- a/cli/cmd/proxy/read/command_test.go +++ b/cli/cmd/proxy/read/command_test.go @@ -146,60 +146,71 @@ func TestReadCommandOutput(t *testing.T) { func TestFilterWarnings(t *testing.T) { podName := "fakePod" cases := map[string]struct { - input []string - shouldWarn bool + input []string + warnings []string }{ "fully qualified domain name doesn't apply to listeners": { - input: []string{"-fqdn", "default", "-listeners"}, - shouldWarn: true, + input: []string{"-fqdn", "default", "-listeners"}, + warnings: []string{"The filter `-fqdn default` does not apply to the tables displayed."}, }, "fully qualified domain name doesn't apply to routes": { - input: []string{"-fqdn", "default", "-routes"}, - shouldWarn: true, + input: []string{"-fqdn", "default", "-routes"}, + warnings: []string{"The filter `-fqdn default` does not apply to the tables displayed."}, }, "fully qualified domain name doesn't apply to endpoints": { - input: []string{"-fqdn", "default", "-endpoints"}, - shouldWarn: true, + input: []string{"-fqdn", "default", "-endpoints"}, + warnings: []string{"The filter `-fqdn default` does not apply to the tables displayed."}, }, "fully qualified domain name doesn't apply to secrets": { - input: []string{"-fqdn", "default", "-secrets"}, - shouldWarn: true, + input: []string{"-fqdn", "default", "-secrets"}, + warnings: []string{"The filter `-fqdn default` does not apply to the tables displayed."}, }, "fully qualified domain name doesn't apply to endpoints or listeners": { - input: []string{"-fqdn", "default", "-endpoints", "-listeners"}, - shouldWarn: true, + input: []string{"-fqdn", "default", "-endpoints", "-listeners"}, + warnings: []string{"The filter `-fqdn default` does not apply to the tables displayed."}, }, "fully qualified domain name doesn't apply to listeners, routes, endpoints, or secrets": { - input: []string{"-fqdn", "default", "-listeners", "-routes", "-endpoints", "-secrets"}, - shouldWarn: true, + input: []string{"-fqdn", "default", "-listeners", "-routes", "-endpoints", "-secrets"}, + warnings: []string{"The filter `-fqdn default` does not apply to the tables displayed."}, }, "port doesn't apply to routes": { - input: []string{"-port", "8080", "-routes"}, - shouldWarn: true, + input: []string{"-port", "8080", "-routes"}, + warnings: []string{"The filter `-port 8080` does not apply to the tables displayed."}, }, "port doesn't apply to secrets": { - input: []string{"-port", "8080", "-secrets"}, - shouldWarn: true, + input: []string{"-port", "8080", "-secrets"}, + warnings: []string{"The filter `-port 8080` does not apply to the tables displayed."}, }, "port doesn't apply to secrets or routes": { - input: []string{"-port", "8080", "-secrets", "-routes"}, - shouldWarn: true, + input: []string{"-port", "8080", "-secrets", "-routes"}, + warnings: []string{"The filter `-port 8080` does not apply to the tables displayed."}, }, "address does not apply to routes": { - input: []string{"-address", "127.0.0.1", "-routes"}, - shouldWarn: true, + input: []string{"-address", "127.0.0.1", "-routes"}, + warnings: []string{"The filter `-address 127.0.0.1` does not apply to the tables displayed."}, }, "address does not apply to secrets": { - input: []string{"-address", "127.0.0.1", "-secrets"}, - shouldWarn: true, + input: []string{"-address", "127.0.0.1", "-secrets"}, + warnings: []string{"The filter `-address 127.0.0.1` does not apply to the tables displayed."}, }, - "multiple warnings": { - input: []string{"-address", "127.0.0.1", "-port", "8080", "-secrets"}, - shouldWarn: true, + "warn address and port": { + input: []string{"-address", "127.0.0.1", "-port", "8080", "-secrets"}, + warnings: []string{ + "The filter `-address 127.0.0.1` does not apply to the tables displayed.", + "The filter `-port 8080` does not apply to the tables displayed.", + }, + }, + "warn fqdn, address, and port": { + input: []string{"-fqdn", "default", "-address", "127.0.0.1", "-port", "8080", "-secrets"}, + warnings: []string{ + "The filter `-fqdn default` does not apply to the tables displayed.", + "The filter `-address 127.0.0.1` does not apply to the tables displayed.", + "The filter `-port 8080` does not apply to the tables displayed.", + }, }, "no warning produced (happy case)": { - input: []string{"-fqdn", "default", "-clusters"}, - shouldWarn: false, + input: []string{"-fqdn", "default", "-clusters"}, + warnings: []string{}, }, } @@ -222,10 +233,8 @@ func TestFilterWarnings(t *testing.T) { exitCode := c.Run(append([]string{podName}, tc.input...)) require.Equal(t, 0, exitCode) // This shouldn't error out, just warn the user. - if tc.shouldWarn { - require.Regexp(t, "The filter.*does not apply to the tables displayed.", buf.String()) - } else { - require.NotRegexp(t, "The filter.*does not apply to the tables displayed.", buf.String()) + for _, warning := range tc.warnings { + require.Contains(t, buf.String(), warning) } }) } From e397a69dbfe0e93d2b8c3453a3deb7046ec03d31 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Mon, 22 Aug 2022 11:39:23 -0400 Subject: [PATCH 13/13] Add changelog improvements --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 650fa52068..cd40a75e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## UNRELEASED +IMPROVEMENTS: +* CLI: + * Display clusters by their short names rather than FQDNs for the `proxy read` command. [[GH-1412](https://github.com/hashicorp/consul-k8s/pull/1412)] + * Display a message when `proxy list` returns no results. [[GH-1412](https://github.com/hashicorp/consul-k8s/pull/1412)] + * Display a warning when a user passes a field and table filter combination to `proxy read` where the given field is not present in any of the output tables. [[GH-1412](https://github.com/hashicorp/consul-k8s/pull/1412)] + ## 0.47.1 (August 12, 2022) BUG FIXES: