-
Notifications
You must be signed in to change notification settings - Fork 116
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 2074304: generateRouteHostRegexp: Escape blanks #381
Bug 2074304: generateRouteHostRegexp: Escape blanks #381
Conversation
@Miciah: An error was encountered searching for bug 2074304 on the Bugzilla server at https://bugzilla.redhat.com. No known errors were detected, please see the full error message for details. Full error message.
code 102: You are not authorized to access bug #2074304. Most likely the bug has been restricted for internal development processes and we cannot grant access. If your role requires it then you may be able to use the self service Request Group Membership workflow to gain the permissions required to access this bug. If you are a Red Hat customer with an active subscription, please visit the Red Hat Customer Portal for assistance with your issue If you are a Fedora Project user and require assistance, please consider using one of the mailing lists we host for the Fedora Project.
Please contact an administrator to resolve this issue, then request a bug refresh with In response to this:
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. |
897c562
to
e5b6d57
Compare
/assign @candita |
pkg/router/template/util/util.go
Outdated
// HAProxy map files. See | ||
// <https://bugzilla.redhat.com/show_bug.cgi?id=2074304>. | ||
pathRE = strings.ReplaceAll(pathRE, " ", "\\ ") | ||
pathRE = strings.ReplaceAll(pathRE, "\t", "\\\t") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also have to consider newlines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newlines don't seem to cause a problem:
% oc -n openshift-ingress-canary create route edge test-route-with-path-with-cr --service=ingress-canary --path=$'/foo\rbar'
route.route.openshift.io/test-route-with-path-with-cr created
% oc -n openshift-ingress logs -c router -l ingresscontroller.operator.openshift.io/deployment-ingresscontroller=default --tail=5
I0412 19:04:47.854197 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:05:02.484520 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:06:08.034955 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:07:23.523944 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:13:26.570714 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
W0412 19:04:57.246318 1 reflector.go:442] github.com/openshift/router/pkg/router/controller/factory/factory.go:125: watch of *v1.Route ended with: an error on the server ("unable to decode an event from the watch stream: stream error: stream ID 7; INTERNAL_ERROR") has prevented the request from succeeding
I0412 19:05:02.477983 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:06:08.034481 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:07:23.513991 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:13:26.571833 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
% oc -n openshift-ingress-canary create route edge test-route-with-path-with-ln --service=ingress-canary --path=$'/foo\nbar'
route.route.openshift.io/test-route-with-path-with-ln created
% oc -n openshift-ingress logs -c router -l ingresscontroller.operator.openshift.io/deployment-ingresscontroller=default --tail=5
I0412 19:05:02.484520 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:06:08.034955 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:07:23.523944 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:13:26.570714 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:13:36.540289 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:05:02.477983 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:06:08.034481 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:07:23.513991 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:13:26.571833 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
I0412 19:13:36.542543 1 router.go:618] template "msg"="router reloaded" "output"=" - Checking http://localhost:80 ...\n - Health check ok : 0 retry attempt(s).\n"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, but I do see the following in the map file:
^test-route-with-path-with-ln-openshift-ingress-canary\.apps\.ci-ln-kliwjz2-72292\.origin-ci-int-gce\.dev\.rhcloud\.com\.?(:[0-9]+)?/foo
bar(/.*)?$ 0
bar(/.*)?$ 0with-path-with-cr-openshift-ingress-canary\.apps\.ci-ln-kliwjz2-72292\.origin-ci-int-gce\.dev\.rhcloud\.com\.?(:[0-9]+)?/foo
I'll add a check for \n
.
/lgtm |
I saw @candita had some questions, so... /hold |
@@ -51,6 +51,12 @@ func GenerateRouteRegexp(hostname, path string, wildcard bool) string { | |||
subpathRE = "(/.*)?" | |||
} | |||
|
|||
// The path could contain space characters, which must be escaped in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the host also contain space characters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the API would reject it:
% oc -n openshift-ingress-canary create route edge test-route-with-host-with-space --service=ingress-canary --hostname='www.foo bar.com'
The Route "test-route-with-host-with-space" is invalid:
* spec.host: Invalid value: "www.foo bar.com": host must conform to DNS 952 subdomain conventions
* spec.host: Invalid value: "www.foo bar.com": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
zsh: exit 1 oc -n openshift-ingress-canary create route edge --service=ingress-canary
e5b6d57
to
ea64335
Compare
ea64335
to
5f31d3b
Compare
/unhold |
Escape spaces, tabs, carriage returns, and linefeeds in the regular expression for a route's path in HAProxy map files in order to ensure that HAProxy can parse the resulting map files correctly. Follow-up to commit 019c5ac. This commit fixes bug 2074304. https://bugzilla.redhat.com/show_bug.cgi?id=2074304 * pkg/router/template/util/haproxy/map_entry_test.go (TestGenerateHttpRedirectMapEntry): Add a test with a path with a space, a test with a path with a tab, a test with a path with a carriage return, and a test with a path with a linefeed. * pkg/router/template/util/util.go (GenerateRouteRegexp): Escape spaces, tabs, carriage returns, and linefeeds in the pattern for the route's path.
5f31d3b
to
30dd5b7
Compare
Turns out |
Here are the results of my testing with the current iteration of this PR:
No errors logged, and the map files look reasonable. |
/retest |
@Miciah: The following test failed, say
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. |
/lgtm |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
17 similar comments
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
/skip |
/bugzilla refresh |
@Miciah: Bugzilla bug 2074304 is in a bug group that is not in the allowed groups for this repo.
In response to this:
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. |
/label valid-bug |
@Miciah: The label(s) In response to this:
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. |
/label bugzilla/valid-bug |
@Miciah: The label(s) In response to this:
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. |
/cherry-pick release-4.10 |
@Miciah: new pull request created: #385 In response to this:
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. |
Escape spaces, tabs, carriage returns, and linefeeds in the regular expression for a route's path in HAProxy map files in order to ensure that HAProxy can parse the resulting map files correctly.
Follow-up to #343.
pkg/router/template/util/haproxy/map_entry_test.go
(TestGenerateHttpRedirectMapEntry
): Add a test with a path with a space, a test with a path with a tab, a test with a path with a carriage return, and a test with a path with a linefeed.pkg/router/template/util/util.go
(GenerateRouteRegexp
): Escape spaces, tabs, carriage returns, and linefeeds in the pattern for the route's path.