-
Notifications
You must be signed in to change notification settings - Fork 17
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
support for default_backend #222
Conversation
d-h1
commented
Apr 26, 2017
•
edited
Loading
edited
- support for setting service as default backend with new serviceDefaultBackend label.
- related issue: haproxy.tmpl doesn't set a default_backend #220
docs/usage.md
Outdated
@@ -25,6 +25,7 @@ The following query parameters can be used to send a *reconfigure* request to *D | |||
|reqMode |The request mode. The proxy should be able to work with any mode supported by HAProxy. However, actively supported and tested modes are `http`, `tcp`, and `sni`. The `sni` mode implies TCP with an SNI-based routing.<br>Example: `tcp`|No|http| | |||
|reqPathReplace |A regular expression to apply the modification. If specified, `reqPathSearch` needs to be set as well.<br>Example: `/demo/`|No| | | |||
|reqPathSearch |A regular expression to search the content to be replaced. If specified, `reqPathReplace` needs to be set as well.<br>Example: `/something/`|No| | | |||
|ServiceDefaultBackend | If true, the service will be set to the default_backend rule, meaning it will catch all requests not matching any other rules.<br>Example: `true`|No| | |
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.
ServiceDefaultBackend
might be confusing. People might expect to put some value other than true
. Maybe it would be better to name it isDefaultBackend
?
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.
I agree, isDefaultBackend sounds much better, I'll update my PR
One more thing... Can you add a test to https://github.com/vfarcic/docker-flow-proxy/blob/master/integration_tests/integration_swarm_test.go? |
The integration test turned out to be more complicated than I thought. My excuse is that I'm a complete newbie in golang... To test isDefaultBackend properly we'd need to:
I'm not sure how to do step 3.. |
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.
Apart from the two minor comments, this looks great.
I'll take care of integration tests (hopefully during the weekend).
server/server_test.go
Outdated
@@ -759,6 +760,7 @@ func (s *ServerTestSuite) Test_GetServicesFromEnvVars_ReturnsServices() { | |||
os.Setenv("DFP_SERVICE_DISTRIBUTE", strconv.FormatBool(service.Distribute)) | |||
os.Setenv("DFP_SERVICE_HTTPS_ONLY", strconv.FormatBool(service.HttpsOnly)) | |||
os.Setenv("DFP_SERVICE_HTTPS_PORT", strconv.Itoa(service.HttpsPort)) | |||
os.Setenv("DFP_SERVICE_DEFAULT_BACKEND", strconv.FormatBool(service.IsDefaultBackend)) |
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.
Why not call it DFP_SERVICE_IS_DEFAULT_BACKEND
? That would make it consistent and easy to remember that env. var. names are the same as request params with the DFP_SERVICE_
prefix.
docs/usage.md
Outdated
@@ -21,6 +21,7 @@ The following query parameters can be used to send a *reconfigure* request to *D | |||
|delReqHeader |Additional headers that will be deleted in the request before forwarding it to the service. Multiple headers should be separated with comma (`,`). Please consult [Delete a header in the request](https://www.haproxy.com/doc/aloha/7.0/haproxy/http_rewriting.html#delete-a-header-in-the-request) for more info.<br>Example: `X-Forwarded-For,Cookie`|No| | | |||
|delResHeader |Additional headers that will be deleted in the response before forwarding it to the client. Multiple headers should be separated with comma (`,`). Please consult [Delete a header in the response](https://www.haproxy.com/doc/aloha/7.0/haproxy/http_rewriting.html#delete-a-header-in-the-response) for more info.<br>Example: `X-Varnish,X-Cache`|No| | | |||
|httpsPort |The internal HTTPS port of a service that should be reconfigured. The port is used only in the `swarm` mode. If not specified, the `port` parameter will be used instead.<br>Example: `443`|No| | | |||
|isDefaultBackend | If true, the service will be set to the default_backend rule, meaning it will catch all requests not matching any other rules.<br>Example: `true`|No| | |
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.
Can you also add an entry in the Environment Variables
section below?
I'd like to run past you a scenario for integration tests.
If my understanding is correct, default backend should forward a request to an address so the above scenario should work. Am I correct in my assumption. If I am, I'll add the test ASAP. |
Take a look at https://gist.github.com/vfarcic/c26a46defba4ff84d1ac7f918fd80c25 and let me know if you think that would be a valid test. If it is, please add it to the PR. |
You are right! That integration test should be good enough to try isDefaultBackend, thanks for the help.. I have a new issue now, when I change "DFP_SERVICE_DEFAULT_BACKEND" to "DFP_SERVICE_IS_DEFAULT_BACKEND" the test "Test_GetServicesFromEnvVars_ReturnsServices" seems to fail and I'm not sure why? |
The problem is in I fixed it and merged the PR. If all the tests pass, it'll be ready for a release. |
Integration tests were missing |