-
Notifications
You must be signed in to change notification settings - Fork 170
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
[THREESCALE-2540] Fix issues with uppercase upstreams. #1044
Conversation
1ff991f
to
15dfaaa
Compare
@@ -98,6 +102,11 @@ function _M:access(context) | |||
end | |||
|
|||
function _M:content(context) | |||
if not context[self].upstream then | |||
ngx.log(ngx.WARN, "Upstream server not found for this request") |
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'm not sure here, but I think that something like this need to be in place, but I'm not sure.
ngx.status = 504
ngx.print('')
return exit()
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 is this if
needed? Shouldn't we treat this case like we did up until now with the assert below?
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.
The thing is if you have 3 services and one is not correctly set, APICast will die and other services will be affected.
With this solution, the current service will not work but others will be not affected at all.
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 think that we need a test case showing that apicast no longer crashes in that case.
context[self].upstream = p.get_upstream(service) | ||
context[self].upstream, err = p.get_upstream(service) | ||
if err then | ||
ngx.log(ngx.WARN, "Backend api for the service=", service.id, " is invalid, error:", err) |
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.
Usually, the logs start with a lower case letter, also it is more common to use :
rather than =
Also, it is not really "backend api", but rather "upstream"
Signed-off-by: Eloy Coto <[email protected]>
In case of a invalid upstream url log a warning error, and don't kill all process. Signed-off-by: Eloy Coto <[email protected]>
Integration test to validate that a upstream with uppercase do not crash and works correctly. Signed-off-by: Eloy Coto <[email protected]>
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.
Excellent 👍
If the proxy API backend is in uppercase it'll not work correctly and
Apicast exists with an execpetion [0]. This commit transform api_backend
always to lowercase string, so the system will not break even if
receives a uppercase string.
[0] Exception
Fix THREESCALE-2540
Signed-off-by: Eloy Coto [email protected]