THREESCALE-8006 fix(oidc): set request timeout for OIDC query - #1601
THREESCALE-8006 fix(oidc): set request timeout for OIDC query#1601tkan145 wants to merge 2 commits into
Conversation
a9e3892 to
cbdb5cb
Compare
Set the connection timeout to 5s to prevent request hanging idenfinetely when an OIDC issuer is unreachable or slow to respond.
cbdb5cb to
46f510d
Compare
borisurbanik
left a comment
There was a problem hiding this comment.
There is one gotcha here that needs a fix. Because remote_v2 is loading oidc on its own, the oidc loader is only used when local-file configuration is provided. The remote_v2 loader bypasses resty/oidc/discovery.new (see the custom client here
APIcast/gateway/src/apicast/configuration_loader/remote_v2.lua
Lines 35 to 41 in 1b0032e
| if err then | ||
| ngx.log(ngx.ERR, 'OIDC discovery failed for service ', service.id, | ||
| ' (issuer: ', service.proxy.oidc_issuer_endpoint or 'nil', '): ', | ||
| result) |
There was a problem hiding this comment.
in the error log message - the discovery method returns nil on error, I think you meant to log err here instead of result
|
|
||
| -- First service should have error | ||
| assert.equals(21, decoded.oidc[1].service_id) | ||
| -- assert.is_not_nil(decoded.oidc[1].error) |
There was a problem hiding this comment.
There is no functionality implemented to leave or check that there was a timeout error during configuration loading. Once it times out here that service will simply fail on JWT verification later.
I'm assuming that's intentional? Or should we make sure there will be some lazy loading for the failing services later? The JIRA was open to address an oidc service that never loads so it's probably intentional, just wanted to confirm.
There was a problem hiding this comment.
It's designed this way; there's no need to retry the OIDC configuration on every request, which would only add unnecessary latency. APIcast will reload the configuration every 5 minutes or so, and then reload the entire OIDC anyway.
Good catch, fixed. Thanks |
What
Fix https://redhat.atlassian.net/browse/THREESCALE-8006
Verification steps
You should see the gateway hang for 5s then start as normal
APICAST_OIDC_CONNECT_TIMEOUT: "20"to docker-compose file