Commit 045cd857 authored by Jerzy Szczepkowski's avatar Jerzy Szczepkowski

Merge pull request #12699 from xiejunan/probe_extractport

fix error in findPortByName
parents 36f94fab f5446f2a
...@@ -255,7 +255,7 @@ func extractPort(param util.IntOrString, container api.Container) (int, error) { ...@@ -255,7 +255,7 @@ func extractPort(param util.IntOrString, container api.Container) (int, error) {
func findPortByName(container api.Container, portName string) (int, error) { func findPortByName(container api.Container, portName string) (int, error) {
for _, port := range container.Ports { for _, port := range container.Ports {
if port.Name == portName { if port.Name == portName {
return port.HostPort, nil return port.ContainerPort, nil
} }
} }
return 0, fmt.Errorf("port %s not found", portName) return 0, fmt.Errorf("port %s not found", portName)
......
...@@ -48,12 +48,12 @@ func TestFindPortByName(t *testing.T) { ...@@ -48,12 +48,12 @@ func TestFindPortByName(t *testing.T) {
container := api.Container{ container := api.Container{
Ports: []api.ContainerPort{ Ports: []api.ContainerPort{
{ {
Name: "foo", Name: "foo",
HostPort: 8080, ContainerPort: 8080,
}, },
{ {
Name: "bar", Name: "bar",
HostPort: 9000, ContainerPort: 9000,
}, },
}, },
} }
...@@ -85,7 +85,7 @@ func TestGetURLParts(t *testing.T) { ...@@ -85,7 +85,7 @@ func TestGetURLParts(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
state := api.PodStatus{PodIP: "127.0.0.1"} state := api.PodStatus{PodIP: "127.0.0.1"}
container := api.Container{ container := api.Container{
Ports: []api.ContainerPort{{Name: "found", HostPort: 93}}, Ports: []api.ContainerPort{{Name: "found", ContainerPort: 93}},
LivenessProbe: &api.Probe{ LivenessProbe: &api.Probe{
Handler: api.Handler{ Handler: api.Handler{
HTTPGet: test.probe, HTTPGet: test.probe,
...@@ -138,7 +138,7 @@ func TestGetTCPAddrParts(t *testing.T) { ...@@ -138,7 +138,7 @@ func TestGetTCPAddrParts(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
host := "1.2.3.4" host := "1.2.3.4"
container := api.Container{ container := api.Container{
Ports: []api.ContainerPort{{Name: "found", HostPort: 93}}, Ports: []api.ContainerPort{{Name: "found", ContainerPort: 93}},
LivenessProbe: &api.Probe{ LivenessProbe: &api.Probe{
Handler: api.Handler{ Handler: api.Handler{
TCPSocket: test.probe, TCPSocket: test.probe,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment