Skip to content

Keep Keycloak SPI timeout below Keycloak's 3s hard limit#672

Merged
AlexGodbehere merged 1 commit into
mainfrom
ago/fix-keycloak-spi-timeout
Jul 9, 2026
Merged

Keep Keycloak SPI timeout below Keycloak's 3s hard limit#672
AlexGodbehere merged 1 commit into
mainfrom
ago/fix-keycloak-spi-timeout

Conversation

@AlexGodbehere

Copy link
Copy Markdown
Contributor

Summary

Keycloak hard-kills user-storage lookups after 3 seconds (ServicesUtils.timeBoundOne). The Factory+ federation SPI defaulted its own per-request timeout to 5 seconds, and service-setup provisioned the same value into the federation component, so the SPI's timeout could never fire: Keycloak always interrupted the thread first.

The functional consequence is diagnostic, not behavioural. When the F+ auth service is slow (as during the ACL storm fixed by #671), login fails either way, but the log shows an opaque InterruptedException inside HttpClientImpl.send instead of a clean HttpTimeoutException naming the F+ auth call. That cost real time when diagnosing the rc.1 login failure.

Changes

  • FactoryPlusUserStorageProviderFactory.DEFAULT_TIMEOUT_SECONDS: 5 → 2, with a comment explaining the 3s ceiling.
  • The auth.timeout.seconds help text now warns that values of 3s or more never take effect.
  • acs-service-setup/lib/openid.js: provisioned federation config 5 → 2 to match.

How to test

  1. mvn test in acs-keycloak-spi: 80 tests, all passing.
  2. On a deployed cluster, block the auth service (e.g. scale it to 0) and attempt a Grafana login. The openid pod log should show a timeout exception naming http://auth.factory-plus... after ~2s rather than an InterruptedException at 3s.
  3. Re-run service-setup; the federation component in Keycloak (Admin console → User federation → factoryplus) should show Request timeout = 2.

Keycloak kills user-storage lookups at 3 seconds
(ServicesUtils.timeBoundOne), so the SPI's 5-second request timeout
could never fire. When the F+ auth service was slow the thread was
interrupted mid-request and the log showed an opaque
InterruptedException rather than a timeout naming the slow hop.

Default the SPI timeout to 2 seconds and set the same value in the
federation component service-setup provisions.
@AlexGodbehere AlexGodbehere force-pushed the ago/fix-keycloak-spi-timeout branch from e617a34 to 6a06d78 Compare July 9, 2026 11:46
@AlexGodbehere AlexGodbehere merged commit eabefb7 into main Jul 9, 2026
1 check passed
@AlexGodbehere AlexGodbehere deleted the ago/fix-keycloak-spi-timeout branch July 9, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant