From 6d1da5bb4589b72f2b930c420564acab13cffea8 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Mon, 17 Jun 2019 20:50:21 +0300 Subject: [PATCH] Use container name in port discovery If the port name is missing, append the container name to the tcp port name --- pkg/canary/deployer.go | 2 +- pkg/controller/scheduler_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/canary/deployer.go b/pkg/canary/deployer.go index 45a56879..fdeb2fbc 100644 --- a/pkg/canary/deployer.go +++ b/pkg/canary/deployer.go @@ -367,7 +367,7 @@ func (c *Deployer) getPorts(deployment *appsv1.Deployment, canaryPort int32) (ma if p.ContainerPort == canaryPort { continue } - name := fmt.Sprintf("tcp-%v", i) + name := fmt.Sprintf("tcp-%s-%v", container.Name, i) if p.Name != "" { name = p.Name } diff --git a/pkg/controller/scheduler_test.go b/pkg/controller/scheduler_test.go index 67e45959..32ba819d 100644 --- a/pkg/controller/scheduler_test.go +++ b/pkg/controller/scheduler_test.go @@ -361,7 +361,7 @@ func TestScheduler_PortDiscovery(t *testing.T) { case "http 9898", "http-metrics 8080", - "tcp-2 8888": + "tcp-podinfo-2 8888": return true } return false