Repository: kumahq/kuma
Pull request #1182 (2020-11-20 10:23:20)

chore(test) change external services test container (bp #1181)
This is an automated backport of pull request #1181 done by Mergify
---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the [documentation](https://docs.mergify.io/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on `<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.io/) you can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.io/
</details>



Patch:
diff --git a/pkg/xds/envoy/listeners/tcp_proxy_configurer.go b/pkg/xds/envoy/listeners/tcp_proxy_configurer.go
index eacde1842..97658bf3a 100644
--- a/pkg/xds/envoy/listeners/tcp_proxy_configurer.go
+++ b/pkg/xds/envoy/listeners/tcp_proxy_configurer.go
@@ -25,6 +25,9 @@ type TcpProxyConfigurer struct {
 }
 
 func (c *TcpProxyConfigurer) Configure(filterChain *envoy_listener.FilterChain) error {
+	if len(c.clusters) == 0 {
+		return nil
+	}
 	tcpProxy := c.tcpProxy()
 
 	pbst, err := proto.MarshalAnyDeterministic(tcpProxy)
diff --git a/pkg/xds/generator/outbound_proxy_generator.go b/pkg/xds/generator/outbound_proxy_generator.go
index e3e900d1f..8e046ece7 100644
--- a/pkg/xds/generator/outbound_proxy_generator.go
+++ b/pkg/xds/generator/outbound_proxy_generator.go
@@ -8,6 +8,7 @@ import (
 
 	"github.com/pkg/errors"
 
+	"github.com/kumahq/kuma/pkg/core"
 	"github.com/kumahq/kuma/pkg/core/validators"
 	envoy_names "github.com/kumahq/kuma/pkg/xds/envoy/names"
 
@@ -21,6 +22,8 @@ import (
 	envoy_listeners "github.com/kumahq/kuma/pkg/xds/envoy/listeners"
 )
 
+var outboundLog = core.Log.WithName("outbound-proxy-generator")
+
 // OriginOutbound is a marker to indicate by which ProxyGenerator resources were generated.
 const OriginOutbound = "outbound"
 
@@ -212,8 +215,9 @@ func (_ OutboundProxyGenerator) determineSubsets(proxy *model.Proxy, outbound *k
 	oface := proxy.Dataplane.Spec.Networking.ToOutboundInterface(outbound)
 
 	route := proxy.TrafficRoutes[oface]
-	if route == nil { // should not happen since we always generate default route if TrafficRoute is not found
-		return nil, errors.Errorf("no TrafficRoute for outbound %s", oface)
+	if route == nil {
+		outboundLog.Info("there is no selected TrafficRoute for the outbound interface, which means that the traffic won't be routed. Visit https://kuma.io/docs/latest/policies/traffic-route/ to check how to introduce the routing.", "dataplane", proxy.Dataplane.Meta.GetName(), "mesh", proxy.Dataplane.Meta.GetMesh(), "outbound", oface)
+		return nil, nil
 	}
 
 	for j, destination := range route.Spec.GetConf().GetSplit() {


Test patch:
diff --git a/pkg/xds/generator/outbound_proxy_generator_test.go b/pkg/xds/generator/outbound_proxy_generator_test.go
index 8cb1a0fdd..08d37d304 100644
--- a/pkg/xds/generator/outbound_proxy_generator_test.go
+++ b/pkg/xds/generator/outbound_proxy_generator_test.go
@@ -277,6 +277,10 @@ var _ = Describe("OutboundProxyGenerator", func() {
 							},
 						},
 					},
+					mesh_proto.OutboundInterface{
+						DataplaneIP:   "127.0.0.1",
+						DataplanePort: 4040,
+					}: nil,
 				},
 				OutboundSelectors: model.DestinationMap{
 					"api-http": model.TagSelectorSet{
@@ -457,6 +461,22 @@ var _ = Describe("OutboundProxyGenerator", func() {
 `,
 			expected: "06.envoy.golden.yaml",
 		}),
+		Entry("07. no TrafficRoute", testCase{
+			ctx: mtlsCtx,
+			dataplane: `
+            networking:
+              address: 10.0.0.1
+              inbound:
+              - port: 8080
+                tags:
+                  kuma.io/service: web
+              outbound:
+              - port: 4040
+                tags:
+                  kuma.io/service: service-without-traffic-route
+`,
+			expected: "07.envoy.golden.yaml",
+		}),
 	)
 
 	It("Add sanitized alternative cluster name for stats", func() {
diff --git a/pkg/xds/generator/testdata/outbound-proxy/07.envoy.golden.yaml b/pkg/xds/generator/testdata/outbound-proxy/07.envoy.golden.yaml
new file mode 100644
index 000000000..affdac5cb
--- /dev/null
+++ b/pkg/xds/generator/testdata/outbound-proxy/07.envoy.golden.yaml
@@ -0,0 +1,12 @@
+resources:
+  - name: outbound:127.0.0.1:4040
+    resource:
+      '@type': type.googleapis.com/envoy.api.v2.Listener
+      address:
+        socketAddress:
+          address: 127.0.0.1
+          portValue: 4040
+      filterChains:
+        - {}
+      name: outbound:127.0.0.1:4040
+      trafficDirection: OUTBOUND
diff --git a/test/e2e/externalservices_kubernetes_test.go b/test/e2e/externalservices_kubernetes_test.go
index aeeedec9a..c68f78554 100644
--- a/test/e2e/externalservices_kubernetes_test.go
+++ b/test/e2e/externalservices_kubernetes_test.go
@@ -174,7 +174,7 @@ metadata:
 			"curl", "-v", "-m", "3", "--fail", "http://external-service.mesh")
 		Expect(err).ToNot(HaveOccurred())
 		Expect(stderr).To(ContainSubstring("HTTP/1.1 200 OK"))
-		Expect(stdout).ToNot(ContainSubstring("HTTPS"))
+		Expect(stdout).ToNot(ContainSubstring("externalservice-https-server"))
 	})
 
 	It("should route to external-service over tls", func() {
@@ -185,7 +185,7 @@ metadata:
 			"curl", "-v", "-m", "3", "--fail", "http://external-service.mesh")
 		Expect(err).ToNot(HaveOccurred())
 		Expect(stderr).To(ContainSubstring("HTTP/1.1 200 OK"))
-		Expect(stdout).To(ContainSubstring("HTTPS"))
+		Expect(stdout).To(ContainSubstring("externalservice-https-server"))
 	})
 
 	It("should disable passthrough", func() {
diff --git a/test/e2e/testdata/externalservice-http-server.yaml b/test/e2e/testdata/externalservice-http-server.yaml
index 29ec3f0a7..1e1b4d647 100644
--- a/test/e2e/testdata/externalservice-http-server.yaml
+++ b/test/e2e/testdata/externalservice-http-server.yaml
@@ -36,7 +36,7 @@ spec:
     spec:
       containers:
         - name: echo-server
-          image: kuma-universal
+          image: mendhak/http-https-echo
           imagePullPolicy: IfNotPresent
           readinessProbe:
             httpGet:
@@ -46,13 +46,6 @@ spec:
             periodSeconds: 3
           ports:
             - containerPort: 80
-          command: [ "ncat" ]
-          args:
-            - -lk
-            - -p
-            - "80"
-            - --sh-exec
-            - '/usr/bin/printf "HTTP/1.1 200 OK\n\n Echo\n"'
           resources:
             limits:
               cpu: 50m
diff --git a/test/e2e/testdata/externalservice-https-server.yaml b/test/e2e/testdata/externalservice-https-server.yaml
index e3e06a692..4b75ff694 100644
--- a/test/e2e/testdata/externalservice-https-server.yaml
+++ b/test/e2e/testdata/externalservice-https-server.yaml
@@ -36,25 +36,16 @@ spec:
     spec:
       containers:
         - name: echo-server
-          image: kuma-universal
+          image: mendhak/http-https-echo
           imagePullPolicy: IfNotPresent
           readinessProbe:
             httpGet:
-              scheme: HTTPS
               path: /
-              port: 443
+              port: 80
             initialDelaySeconds: 3
             periodSeconds: 3
           ports:
             - containerPort: 443
-          command: [ "ncat" ]
-          args:
-            - -lk
-            - -p
-            - "443"
-            - --ssl
-            - --sh-exec
-            - '/usr/bin/printf "HTTP/1.1 200 OK\n\n HTTPS Echo\n"'
           resources:
             limits:
               cpu: 50m