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

OCPBUGS-16707: UniqueHost: Fix incorrect identification of conflicting route #508

Conversation

frobware
Copy link
Contributor

@frobware frobware commented Aug 22, 2023

When a route is rejected due to the host already being claimed, it was
always selecting the first route but the first route is not guaranteed
to being the conflicting route.

All routes for the host are retrieved using the 'RoutesForHost'
function and that function returns a slice of routes derived from a
map in the 'hostIndex' structure. Since maps do not guarantee order,
the first route was not necessarily the oldest.

The fix is to first sort the conflicting routes based on their
submission time, and then pick the newest.

Fixes: https://issues.redhat.com/browse/OCPBUGS-16707

@frobware frobware changed the title UniqueHost: Fix incorrect identification of conflicting route OCPBUGS-16707: UniqueHost: Fix incorrect identification of conflicting route Aug 22, 2023
@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 22, 2023
@openshift-ci-robot
Copy link
Contributor

@frobware: This pull request references Jira Issue OCPBUGS-16707, which is invalid:

  • expected the bug to target the "4.14.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

When a route is rejected due to the host already being claimed, the
incorrect route was being identified as the conflicting one. The
problem was that the first route in the array was always being
returned as the conflicting route, instead of the actual conflicting
one.

This fix addresses the issue by returning the last route in the slice,
which corresponds to the correct conflicting route. This ensures that
the "HostAlreadyClaimed" error properly identifies the correct
conflicting route, taking into account both host and path.

Fixes: https://issues.redhat.com/browse/OCPBUGS-16707

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 openshift-ci bot requested review from candita and knobunc August 22, 2023 11:48
@frobware frobware marked this pull request as draft August 22, 2023 12:18
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 22, 2023
@frobware frobware force-pushed the OCPBUGS-17607-Misleading-error-message-to-highlight-HostAlreadyClaimed branch from 3abac27 to 9229a22 Compare August 22, 2023 12:55
@openshift-ci-robot
Copy link
Contributor

@frobware: This pull request references Jira Issue OCPBUGS-16707, which is invalid:

  • expected the bug to target the "4.14.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

When a route is rejected due to the host already being claimed, the
incorrect route was being identified as the conflicting one. The
problem was that the first route in the array was always being
returned as the conflicting route, instead of the actual conflicting
one.

Prior the this change routes were retrieved using the 'RoutesForHost'
function, which returns a slice of routes derived from a map in the
'hostIndex' structure. Since maps do not guarantee order, the first
route was not necessarily the oldest.

This fix addresses the issue by first sorting the conflicting routes
based on their submission time, and then picking the newest.

Fixes: https://issues.redhat.com/browse/OCPBUGS-16707

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.

@frobware frobware force-pushed the OCPBUGS-17607-Misleading-error-message-to-highlight-HostAlreadyClaimed branch from 9229a22 to 606ce07 Compare August 22, 2023 13:10
@openshift-ci-robot
Copy link
Contributor

@frobware: This pull request references Jira Issue OCPBUGS-16707, which is invalid:

  • expected the bug to target the "4.14.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

When a route is rejected due to the host already being claimed, it was
always selecting the first route but the first route is not guaranteed
to being the conflicting route.

All routes for the host are retrieved using the 'RoutesForHost'
function and that function returns a slice of routes derived from a
map in the 'hostIndex' structure. Since maps do not guarantee order,
the first route was not necessarily the oldest.

The fix is to first sort the conflicting routes based on their
submission time, and then pick the newest.

Fixes: https://issues.redhat.com/browse/OCPBUGS-16707

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.

@frobware
Copy link
Contributor Author

@frobware frobware marked this pull request as ready for review August 22, 2023 13:39
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 22, 2023
@frobware
Copy link
Contributor Author

There are no nodes that your pod can schedule to - check your requests, tolerations, and node selectors (0/16 nodes are available

/test all

@candita
Copy link
Contributor

candita commented Aug 23, 2023

/assign @rfredette

@frobware
Copy link
Contributor Author

Too many days, ...
/retest

Comment on lines +184 to +221
sort.SliceStable(old, func(i, j int) bool {
return !routeapihelpers.RouteLessThan(old[i], old[j])
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure this fixes the issue. old here seems to be all the routes with the same host, but I think we also need to take path into account to decide which route conflicts. Sorting all the routes works for the reproducer script from your haproxy-hacks repo, but if I edit the script to create the routes in the order route2 > route1 > route3, then route3 reports that route1 is the conflicting route, even though it's actually route2 that's the problem:

route.route.openshift.io/route2 created
route.route.openshift.io/route1 created
route.route.openshift.io/route3 created
Name:                   route3
Namespace:              ocpbugs16707
Created:                3 seconds ago
Labels:                 <none>
Annotations:            <none>
Requested Host:         httpd-example-path-based-routes.apps.firstcluster.lab.upshift.rdu2.redhat.com
                        rejected by router default:  (host router-default.apps.ci-ln-xxi6972-72292.gcp-2.ci.openshift.org)HostAlreadyClaimed (3 seconds ago)
                          route route1 already exposes httpd-example-path-based-routes.apps.firstcluster.lab.upshift.rdu2.redhat.com and is older
Path:                   /api
TLS Termination:        <none>
Insecure Policy:        <none>
Endpoint Port:          http

Service:        api-service
Weight:         100 (100%)
Endpoints:      <error: endpoints "api-service" not found>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed an update in ca357ed.

When a route is rejected due to the host already being claimed, it was
always selecting the first route but the first route is not guaranteed
to being the conflicting route.

All routes for the host are retrieved using the 'RoutesForHost'
function and that function returns a slice of routes derived from a
map in the 'hostIndex' structure. Since maps do not guarantee order,
the first route was not necessarily the oldest.

The fix is to first sort the conflicting routes based on their
submission time, and then pick the newest.

Fixes: https://issues.redhat.com/browse/OCPBUGS-16707
@frobware frobware force-pushed the OCPBUGS-17607-Misleading-error-message-to-highlight-HostAlreadyClaimed branch from 606ce07 to ca357ed Compare September 4, 2023 12:49
@rfredette
Copy link
Contributor

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 11, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rfredette

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 11, 2023
@frobware
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot
Copy link
Contributor

@frobware: This pull request references Jira Issue OCPBUGS-16707, which is invalid:

  • expected the bug to target the "4.15.0" version, but it targets "4.15" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/jira refresh

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.

@frobware
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Sep 12, 2023
@openshift-ci-robot
Copy link
Contributor

@frobware: This pull request references Jira Issue OCPBUGS-16707, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.15.0) matches configured target version for branch (4.15.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @jitendar-singh

In response to this:

/jira refresh

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.

@frobware
Copy link
Contributor Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 12, 2023

@frobware: all tests passed!

Full PR test history. Your PR dashboard.

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 understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit 6ca3356 into openshift:master Sep 18, 2023
8 checks passed
@openshift-ci-robot
Copy link
Contributor

@frobware: Jira Issue OCPBUGS-16707: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-16707 has been moved to the MODIFIED state.

In response to this:

When a route is rejected due to the host already being claimed, it was
always selecting the first route but the first route is not guaranteed
to being the conflicting route.

All routes for the host are retrieved using the 'RoutesForHost'
function and that function returns a slice of routes derived from a
map in the 'hostIndex' structure. Since maps do not guarantee order,
the first route was not necessarily the oldest.

The fix is to first sort the conflicting routes based on their
submission time, and then pick the newest.

Fixes: https://issues.redhat.com/browse/OCPBUGS-16707

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
Copy link
Contributor

Fix included in accepted release 4.15.0-0.nightly-2023-09-27-073353

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. jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. 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

5 participants