New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1763340: ingress: targetPortForService: Use port name only #24971
Bug 1763340: ingress: targetPortForService: Use port name only #24971
Conversation
When translating the port specified by an Ingress to the target port for a Route, use the port name rather than the number, or omit the target port if it has no name. An Ingress resource specifies a Service and a port on that Service whereas a Route resource specifies a Service and a target port on the corresponding Endpoints resource. The ports on the Endpoints resource and the ports on the Service resources have matching names but may have different numbers. Therefore, when mapping an Ingress and Service to a Route and a target port for the Endpoints resource, we cannot use port numbers; we must use names or omit the target port entirely. It is safe to omit the target port if it does not have a name because a Service port must have a name if the Service has more than one port; therefore if a port is nameless, it must be the only port; and omitting the target port in the Route spec means that every port (or in this case, the only port) on the Endpoints resource is targeted. This commit fixes bug 1760776. https://bugzilla.redhat.com/show_bug.cgi?id=1760776 * pkg/route/ingress/ingress.go (targetPortForService): Add an error return value. Return an error if the Ingress references a Service or port that cannot be found. Otherwise, return the Service port's name as the target port, or return nil if the port has no name. (newRouteForIngress, routeMatchesIngress): Update to check the error value from targetPortForService and to handle a nil target port (which means the Route should have a null port specification). * pkg/route/ingress/ingress_test.go (TestController_stabilizeAfterCreate): Add test case with a nameless port. (TestController_sync): Add a test case where the Ingress references a Service that does not exist. Add a test case where the Ingress specifies a port by number. Update test cases to expect port names in Route port specifications. Update the failure messages for unexpected actions to print the actions. Co-authored-by: derkoe <christian.koeberl@gmail.com>
@Miciah: This pull request references Bugzilla bug 1763340, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I have opened https://bugzilla.redhat.com/show_bug.cgi?id=1835480 for the CI failure. |
/test e2e-gcp |
/approve |
/test e2e-gcp |
9 similar comments
/test e2e-gcp |
/test e2e-gcp |
/test e2e-gcp |
/test e2e-gcp |
/test e2e-gcp |
/test e2e-gcp |
/test e2e-gcp |
/test e2e-gcp |
/test e2e-gcp |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: danehans, knobunc, Miciah The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
4 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
25 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/override ci/prow/e2e-gcp |
@sdodson: Overrode contexts on behalf of sdodson: ci/prow/e2e-gcp In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@Miciah: All pull requests linked via external trackers have merged: openshift/origin#24971. Bugzilla bug 1763340 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
When translating the port specified by an Ingress to the target port for a Route, use the port name rather than the number, or omit the target port if it has no name.
An Ingress resource specifies a Service and a port on that Service whereas a Route resource specifies a Service and a target port on the corresponding Endpoints resource. The ports on the Endpoints resource and the ports on the Service resources have matching names but may have different numbers. Therefore, when mapping an Ingress and Service to a Route and a target port for the Endpoints resource, we cannot use port numbers; we must use names or omit the target port entirely.
It is safe to omit the target port if it does not have a name because a Service port must have a name if the Service has more than one port; therefore if a port is nameless, it must be the only port; and omitting the target port in the Route spec means that every port (or in this case, the only port) on the Endpoints resource is targeted.
pkg/route/ingress/ingress.go
(targetPortForService
): Add an error return value. Return an error if the Ingress references a Service or port that cannot be found. Otherwise, return the Service port's name as the target port, or return nil if the port has no name.(
newRouteForIngress
,routeMatchesIngress
): Update to check the error value fromtargetPortForService
and to handle a nil target port (which means the Route should have a null port specification).pkg/route/ingress/ingress_test.go
(TestController_stabilizeAfterCreate
):Add test case with a nameless port.
(
TestController_sync
): Add a test case where the Ingress references a Service that does not exist. Add a test case where the Ingress specifies a port by number. Update test cases to expect port names in Route port specifications. Update the failure messages for unexpected actions to print the actions.Co-authored-by: derkoe christian.koeberl@gmail.com