Skip to content
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

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented May 12, 2020

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 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 and others added 2 commits May 12, 2020 14:38
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>
@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label May 12, 2020
@openshift-ci-robot
Copy link

@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
  • bug is open, matching expected state (open)
  • bug target release (3.11.z) matches configured target release for branch (3.11.z)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1763340: ingress: targetPortForService: Use port name only

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label May 12, 2020
@Miciah
Copy link
Contributor Author

Miciah commented May 13, 2020

I have opened https://bugzilla.redhat.com/show_bug.cgi?id=1835480 for the CI failure.

@Miciah
Copy link
Contributor Author

Miciah commented May 20, 2020

/test e2e-gcp

@knobunc
Copy link
Contributor

knobunc commented May 20, 2020

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 20, 2020
@Miciah
Copy link
Contributor Author

Miciah commented May 24, 2020

/test e2e-gcp

9 similar comments
@Miciah
Copy link
Contributor Author

Miciah commented May 25, 2020

/test e2e-gcp

@Miciah
Copy link
Contributor Author

Miciah commented May 26, 2020

/test e2e-gcp

@Miciah
Copy link
Contributor Author

Miciah commented May 26, 2020

/test e2e-gcp

@Miciah
Copy link
Contributor Author

Miciah commented May 26, 2020

/test e2e-gcp

@Miciah
Copy link
Contributor Author

Miciah commented May 27, 2020

/test e2e-gcp

@Miciah
Copy link
Contributor Author

Miciah commented May 27, 2020

/test e2e-gcp

@Miciah
Copy link
Contributor Author

Miciah commented May 27, 2020

/test e2e-gcp

@Miciah
Copy link
Contributor Author

Miciah commented May 27, 2020

/test e2e-gcp

@Miciah
Copy link
Contributor Author

Miciah commented May 27, 2020

/test e2e-gcp

@danehans
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2020
@openshift-ci-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

4 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

25 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@sdodson
Copy link
Member

sdodson commented Jun 5, 2020

/override ci/prow/e2e-gcp

@openshift-ci-robot
Copy link

@sdodson: Overrode contexts on behalf of sdodson: ci/prow/e2e-gcp

In response to this:

/override ci/prow/e2e-gcp

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.

@openshift-merge-robot openshift-merge-robot merged commit dbda62b into openshift:release-3.11 Jun 5, 2020
@openshift-ci-robot
Copy link

@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:

Bug 1763340: ingress: targetPortForService: Use port name only

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants