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 1896474: HTTPS redirect happens even if there is a more specific http-only route #343

Merged

Conversation

miheer
Copy link
Contributor

@miheer miheer commented Sep 9, 2021

Bug 2002205 - HTTPS redirect happens even if there is a more specific http-only route

Let's say we have 2 routes like this:

  • HTTP-only route for "myapp.apps.example.com" domain and "/mypath" path
  • HTTPS-edge-redirect route for "myapp.apps.example.com" and no path

In such situation, redirect is sent for any query to "myapp.apps.example.com", including "myapp.apps.example.com/mypath", so the more specific path route is not taking precedence as expected.

@miheer miheer force-pushed the path-based-route-issue branch from b2be003 to 5292e24 Compare September 9, 2021 06:46
@miheer miheer changed the title Bug 2002205 - HTTPS redirect happens even if there is a more specific http-only route Bug 1896474 - HTTPS redirect happens even if there is a more specific http-only route Sep 9, 2021
@miheer
Copy link
Contributor Author

miheer commented Sep 9, 2021

/bugzilla refresh

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 9, 2021

@miheer: No Bugzilla bug is referenced in the title of this pull request.
To reference a bug, add 'Bug XXX:' to the title of this pull request and request another bug refresh with /bugzilla refresh.

In response to this:

/bugzilla 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.

@miheer miheer changed the title Bug 1896474 - HTTPS redirect happens even if there is a more specific http-only route Bug 1896474: HTTPS redirect happens even if there is a more specific http-only route Sep 9, 2021
@miheer
Copy link
Contributor Author

miheer commented Sep 9, 2021

/bugzilla refresh

@openshift-ci openshift-ci bot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Sep 9, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 9, 2021

@miheer: This pull request references Bugzilla bug 1896474, which is invalid:

  • expected the bug to target the "4.10.0" release, but it targets "---" instead

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

In response to this:

Bug 1896474: HTTPS redirect happens even if there is a more specific http-only route

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

openshift-ci bot commented Sep 9, 2021

@miheer: This pull request references Bugzilla bug 1896474, which is invalid:

  • expected the bug to target the "4.10.0" release, but it targets "---" instead

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

In response to this:

/bugzilla 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.

@miheer
Copy link
Contributor Author

miheer commented Sep 9, 2021

/bugzilla refresh

@openshift-ci openshift-ci bot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Sep 9, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 9, 2021

@miheer: This pull request references Bugzilla bug 1896474, 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 (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @quarterpin

In response to this:

/bugzilla 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.

@openshift-ci openshift-ci bot requested a review from quarterpin September 9, 2021 08:17
@miheer miheer force-pushed the path-based-route-issue branch 3 times, most recently from 422fbc2 to c6c965d Compare September 10, 2021 19:00
@miheer
Copy link
Contributor Author

miheer commented Sep 10, 2021

I am still working on to fix the unit test as the following is failing ->

=== RUN TestGenerateHAProxyMap
template_helper_test.go:503: TestGenerateHAProxyMap os_route_http_redirect.map error: sorted data ^zzz-production.wildcard.test.?(:[0-9]+)?(/.*)?$ 1 at index 0 did not match suffix expectation test:api-route
--- FAIL: TestGenerateHAProxyMap (0.00s)
FAIL
FAIL github.com/openshift/router/pkg/router/template 0.008s
testing: warning: no tests to run

@miheer miheer force-pushed the path-based-route-issue branch from c6c965d to e2b1441 Compare September 10, 2021 20:27
@miheer
Copy link
Contributor Author

miheer commented Sep 11, 2021

/retest

Comment on lines 483 to 498
"test:api-route",
"dev:reencrypt-route",
"prod:backend-route",
"stg:api-route",
"prod:api-route",
"1",
"0",
"1",
"0",
"0",
"1",
"1",
"0",
"1",
"0",
"0",
"0",
"0",
"0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why include the key and not the value as we discussed?

Comment on lines 62 to 70
if cfg.InsecurePolicy == routev1.InsecureEdgeTerminationPolicyRedirect {
return &HAProxyMapEntry{
Key: templateutil.GenerateRouteRegexp(cfg.Host, cfg.Path, cfg.IsWildcard),
Value: "1",
}
} else {
return &HAProxyMapEntry{
Key: templateutil.GenerateRouteRegexp(cfg.Host, cfg.Path, cfg.IsWildcard),
Value: "0"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix the formatting issue with the } at the end of the line, consider using switch, and reduce code duplication.

@miheer miheer force-pushed the path-based-route-issue branch from e2b1441 to 4b91bf4 Compare September 13, 2021 07:05
@melvinjoseph86
Copy link

/bugzilla cc-qa

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 15, 2021

@melvinjoseph86: This pull request references Bugzilla bug 1896474, which is valid.

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

No GitHub users were found matching the public email listed for the QA contact in Bugzilla (mjoseph@redhat.com), skipping review request.

In response to this:

/bugzilla cc-qa

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.

@melvinjoseph86
Copy link

/lgtm
/label qe-approved

Verified via pre-merge verification workflow, more references related to the test can be found in:
https://bugzilla.redhat.com/show_bug.cgi?id=1896474#c13

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Sep 15, 2021
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2021
@miheer miheer force-pushed the path-based-route-issue branch from 4b91bf4 to 3fcaab2 Compare September 20, 2021 12:06
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 20, 2021
Comment on lines 63 to 69
Key: templateutil.GenerateRouteRegexp(cfg.Host, cfg.Path, cfg.IsWildcard),
}
switch cfg.InsecurePolicy {
case routev1.InsecureEdgeTerminationPolicyRedirect:
haproxyMapEntry.Value = "1"
return haproxyMapEntry
default:
haproxyMapEntry.Value = "0"
return haproxyMapEntry
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified:

Suggested change
Key: templateutil.GenerateRouteRegexp(cfg.Host, cfg.Path, cfg.IsWildcard),
}
switch cfg.InsecurePolicy {
case routev1.InsecureEdgeTerminationPolicyRedirect:
haproxyMapEntry.Value = "1"
return haproxyMapEntry
default:
haproxyMapEntry.Value = "0"
return haproxyMapEntry
}
Key: templateutil.GenerateRouteRegexp(cfg.Host, cfg.Path, cfg.IsWildcard),
Value: "0",
}
switch cfg.InsecurePolicy {
case routev1.InsecureEdgeTerminationPolicyRedirect:
haproxyMapEntry.Value = "1"
}
return haproxyMapEntry

… http-only route

Let's say we have 2 routes like this:
- HTTP-only route for "myapp.apps.example.com" domain and "/mypath" path
- HTTPS-edge-redirect route for "myapp.apps.example.com" and no path

In such situation, redirect is sent for any query to "myapp.apps.example.com", including "myapp.apps.example.com/mypath", so the more specific path route is not taking precedence as expected.
@miheer miheer force-pushed the path-based-route-issue branch from 3fcaab2 to 019c5ac Compare September 23, 2021 09:13
@melvinjoseph86
Copy link

/retest

@melvinjoseph86
Copy link

/retest-required

1 similar comment
@melvinjoseph86
Copy link

/retest-required

@melvinjoseph86
Copy link

/lgtm
/label qe-approved

Verified via pre-merge verification workflow, more references related to the test can be found in:
https://bugzilla.redhat.com/show_bug.cgi?id=1896474#c15

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

miheer commented Sep 27, 2021

@Miciah PTAL. Can you please approve ?

@Miciah
Copy link
Contributor

Miciah commented Sep 27, 2021

Thanks!
/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 27, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: melvinjoseph86, Miciah, miheer

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 27, 2021
@openshift-merge-robot openshift-merge-robot merged commit ddca0a6 into openshift:master Sep 27, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 27, 2021

@miheer: All pull requests linked via external trackers have merged:

Bugzilla bug 1896474 has been moved to the MODIFIED state.

In response to this:

Bug 1896474: HTTPS redirect happens even if there is a more specific http-only route

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.

@melvinjoseph86
Copy link

/bugzilla refresh

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 29, 2021

@melvinjoseph86: Bugzilla bug 1896474 is in an unrecognized state (ON_QA) and will not be moved to the MODIFIED state.

In response to this:

/bugzilla 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.

@miheer
Copy link
Contributor Author

miheer commented Jan 10, 2022

/cherry-pick release-4.9

@openshift-cherrypick-robot

@miheer: new pull request created: #367

In response to this:

/cherry-pick release-4.9

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. qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants