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

fixed rewrites for paths not ending in / #2899

Merged
merged 1 commit into from Aug 19, 2018

Conversation

Projects
8 participants
@jeroenvand
Copy link
Contributor

jeroenvand commented Aug 5, 2018

What this PR does / why we need it:

Make sure that rewrites work correctly for paths without terminating slash.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

fixes #2845.

Special notes for your reviewer:

I did update the unit tests and it runs with errors relating to the rewrite stuff, but I couldn't get the e2e tests to run without failing. Then again, those failed with a clean master branch checkout as well so maybe I did something wrong there altogether.

@k8s-ci-robot k8s-ci-robot added the size/S label Aug 5, 2018

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Aug 5, 2018

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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.

@jeroenvand

This comment has been minimized.

Copy link
Contributor

jeroenvand commented Aug 5, 2018

CLA check fails because committed with the wrong email address. Will fix in a couple of hours.

@jeroenvand

This comment has been minimized.

Copy link
Contributor

jeroenvand commented Aug 6, 2018

CLA signed

@@ -136,7 +136,7 @@ proxy_pass http://upstream-name;
"/",
`~* ^/something\/?(?<baseuri>.*)`,
`
rewrite (?i)/something/(.*) /$1 break;
rewrite (?i)/something(.*) /$1 break;

This comment has been minimized.

@antoineco

antoineco Aug 6, 2018

Contributor

These look a bit dangerous to me, the regexp should match either an end of line ($) or /.*, but not /somethingelse as it would be the case here.

This comment has been minimized.

@jeroenvand

jeroenvand Aug 9, 2018

Contributor

You are correct. I've changed it to only match on end of line or /.*

I'm still having trouble getting the tests to run without issues. The unit tests indicate FAIL, but without any specifics and the e2e tests I've not been able to run successfully at all yet. I did however test an image build from my fork/branch, tested it in our own environment and there it seems to do the right thing.

@aledbf

This comment has been minimized.

Copy link
Member

aledbf commented Aug 9, 2018

/hold

@aledbf

This comment has been minimized.

Copy link
Member

aledbf commented Aug 13, 2018

/hold cancel

@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Aug 15, 2018

Codecov Report

Merging #2899 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2899      +/-   ##
==========================================
+ Coverage   47.57%   47.58%   +<.01%     
==========================================
  Files          77       77              
  Lines        5532     5533       +1     
==========================================
+ Hits         2632     2633       +1     
  Misses       2560     2560              
  Partials      340      340
Impacted Files Coverage Δ
internal/ingress/controller/template/template.go 64.97% <100%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb96cf0...e428095. Read the comment docs.

@jeroenvand

This comment has been minimized.

Copy link
Contributor

jeroenvand commented Aug 15, 2018

@antoineco I've made the changes you suggested and tests now complete successfully. Can you have another look? Thanks!

@aledbf

This comment has been minimized.

Copy link
Member

aledbf commented Aug 15, 2018

@jeroenvand please squash the commits

@jeroenvand jeroenvand force-pushed the jeroenvand:jvd-fix-rewrite branch from f500ac9 to e428095 Aug 15, 2018

@jeroenvand

This comment has been minimized.

Copy link
Contributor

jeroenvand commented Aug 15, 2018

Commits squashed

@antoineco

This comment has been minimized.

Copy link
Contributor

antoineco commented Aug 19, 2018

/lgtm
Thanks @jeroenvand!

@k8s-ci-robot k8s-ci-robot added the lgtm label Aug 19, 2018

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Aug 19, 2018

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: antoineco, jeroenvand

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

@k8s-ci-robot k8s-ci-robot merged commit c083599 into kubernetes:master Aug 19, 2018

3 checks passed

cla/linuxfoundation jeroenvand authorized
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
tide In merge pool.
Details

@aledbf aledbf added this to done in 0.19.0 Aug 19, 2018

@jeroenvand jeroenvand deleted the jeroenvand:jvd-fix-rewrite branch Sep 6, 2018

%v%v %s%s;
%v`, path, location.Path, xForwardedPrefix, proxyPass, proto, upstreamName, abu)
}

return fmt.Sprintf(`
rewrite (?i)%s(.*) %s/$1 break;
rewrite (?i)%s$ %s/ break;

This comment has been minimized.

@miduddin

miduddin Sep 24, 2018

what is the reason for the target to end with slash? forgive me if it's already explained elsewhere but i can't seem to find it.

related issue: #1399

This comment has been minimized.

@ZxYuan

ZxYuan Sep 26, 2018

Also confused.
Any target path that ends without slash cannot be matched in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment