-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Oidc doesn't recover when auth-server was not avaliable at startup #16725
Comments
/cc @pedroigor, @sberyozkin |
@joggeli34 Is it running in the dev mode ? A test is available confirming it recovers in the dev mode after the address is entered. |
Keeping a timer in a production mode is expensive - especially in a multi-tenant case which would require a timer per each tenant. If it is not a dev mode then you should use a |
It happens in dev mode and in production. I don't understand the |
OK, I see - no, as I said no timer is allocated to keep pinging the OIDC server until it may come up. I expect that in production OIDC server is already running - so we are really talking about a test/dev scenario where it may not have started just yet - so yes - if you set this property to 20 sec then it will miss if it will start after 1 min so set to 2 mins. |
Ok, now I understand. Thanks. Normally our OIDC-server (keycloak) is already running, but we had a major issue which triggered the whole cluster to reboot... Would it be an idea that quarkus termines if it can't reach the OIDC server after the connection-delay? Because now the applications stays in a unusable and unrecoverable state forever, when not restarted from outside (liveness-probe). |
@joggeli34 I think I can update the code to give it a single retry when the statically configured OIDC connection is required but it is marked as not initialized. I'll give a try. |
I now tested with different quarkus-versions and noticed that this behavior was introduced in 1.13.1.Final. Is that correct? |
@joggeli34 Yes - it was affecting the user experience in the dev mode. |
I now tested with the parameter settings:
In the dev-mode it doesn't recover even if the oidc-server is up after 1m. It just keeps responding all requests with OICDException.
|
@joggeli34 As I said there is no timer there pinging the unavailable server all the time. In the dev mode one would start with no address at all or some template address - the server would start - you can verify the request fails - next you set a correct address and it works - but here it is slightly different - you just have OIDC server coming up at some point but unless you refresh the dev endpoint somehow, perhaps via a browser, etc, then it won't try to re-initialize. |
I'm sorry and I feel a bit stupid but I still don't get it right. As I understood, the parameter For me it's more a problem in production then in dev. Because when it doesn't work in dev, I just restart. Further there is no log why the oicd is not reachable. I don't even have a log that it is not correctly set up, just some log that the requests to my api are not working correctly because the tenant is not configured. Before 1.13.1 I got a "unknown host" exception if I had a typo in the oicd address. Does the change you propose leads to a shutdown of the application? I don't want to be tedious, probably I just don't understand it correctly, sorry ;-) |
@joggeli34 Np at all, I'll look into it, we'll try to make it right |
Hi @joggeli34 I'll restore the earlier functionality where the application was failing to start when it failed to connect to the OIDC server - but only if It feels it will be the right balance - as going forward we can indeed consider activating a timer, possibly a single one for all the tenants, trying to establish the connection or also doing the liveness pings and trying to restore the connection if it fails after it has been established. The role of Note this |
Thanks, yes that sounds very reasonable this way. |
@joggeli34 Please see #16725. |
Is there any chance this fix will make it to the 1.13.x release line? I stumbled over this issue and was excited when I saw the PR, but just now saw that is was removed from the 1.13.4.final milestone. |
Hi @joggeli34, and @oole I've just noticed only now it was not backported - I messed it up because I removed the test resource which is no longer needed in 2.0.0.x and forgot it was still needed in 1.13.x - but looks like |
@joggeli34 @oole Backport PR is here #17662 |
Great news, thanks @sberyozkin. |
Describe the bug
When runing quarkus with oidc enabled, the application starts even when the oidc-server is currently not avaliable. Each request to the api results in a error:
io.quarkus.oidc.OIDCException: Tenant configuration has not been resolved at io.quarkus.oidc.runtime.OidcAuthenticationMechanism.resolve(OidcAuthenticationMechanism.java:61) at io.quarkus.oidc.runtime.OidcAuthenticationMechanism.authenticate(OidcAuthenticationMechanism.java:40) at io.quarkus.oidc.runtime.OidcAuthenticationMechanism_Subclass.authenticate$$superaccessor2(OidcAuthenticationMechanism_Subclass.zig:512) at io.quarkus.oidc.runtime.OidcAuthenticationMechanism_Subclass$$function$$2.apply(OidcAuthenticationMechanism_Subclass$$function$$2.zig:41) at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:63) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:51) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41) at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41) at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32) ...
Even when the oidc-server gets avaliable after some time, the requests aren't recovering from this error. Not even after the time defined in
quarkus.oidc.token.forced-jwk-refresh-interval
.Expected behavior
The requests should either recover after the oidc-server is back or the application should not start if the oidc-server is not avaliable.
Configuration
Environment:
Quarkus version or git rev
1.13.2.Final
The text was updated successfully, but these errors were encountered: