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

fixed rewrites for paths not ending in / #2899

Merged
merged 1 commit into from
Aug 19, 2018
Merged

fixed rewrites for paths not ending in / #2899

merged 1 commit into from
Aug 19, 2018

Conversation

jeroenvand
Copy link
Contributor

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 Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 5, 2018
@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 5, 2018
@jeroenvand
Copy link
Contributor Author

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

@jeroenvand
Copy link
Contributor Author

CLA signed

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 6, 2018
@@ -136,7 +136,7 @@ proxy_pass http://upstream-name;
"/",
`~* ^/something\/?(?<baseuri>.*)`,
`
rewrite (?i)/something/(.*) /$1 break;
rewrite (?i)/something(.*) /$1 break;
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

aledbf commented Aug 9, 2018

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 9, 2018
@aledbf
Copy link
Member

aledbf commented Aug 13, 2018

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 13, 2018
@codecov-io
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
Copy link
Contributor Author

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

@aledbf
Copy link
Member

aledbf commented Aug 15, 2018

@jeroenvand please squash the commits

@jeroenvand
Copy link
Contributor Author

Commits squashed

@antoineco
Copy link
Contributor

/lgtm
Thanks @jeroenvand!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 19, 2018
@k8s-ci-robot
Copy link
Contributor

[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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 19, 2018
@k8s-ci-robot k8s-ci-robot merged commit c083599 into kubernetes:master Aug 19, 2018
@jeroenvand jeroenvand deleted the jvd-fix-rewrite branch September 6, 2018 12:04
%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;

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

location allows hitting path without terminating slash, rewrite-target doesn't unless it's set to '/'
8 participants