CAMEL-24815: camel-opensearch - honour socketTimeout without SSL and scope basic auth to all hosts - #26589
CAMEL-24815: camel-opensearch - honour socketTimeout without SSL and scope basic auth to all hosts#26589oscerd wants to merge 1 commit into
Conversation
…scope basic auth to all hosts OpensearchProducer.createClient() diverged from the camel-elasticsearch producer in two ways: - socketTimeout was applied only inside the enableSSL branch (via the pooling connection manager), so plain-HTTP endpoints ignored it and a stalled node could block the caller indefinitely. Add setResponseTimeout to the request-config callback so the read timeout applies with and without SSL. - basic-auth credentials were registered with AuthScope bound to the first configured host, so multi-host clusters returned 401 on every other node. Use a match-all AuthScope so credentials are sent to all nodes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet-bot
left a comment
There was a problem hiding this comment.
Two correct bug fixes, well-scoped.
Fix 1 — socketTimeout on plain-HTTP: Adding setResponseTimeout(...) to the setRequestConfigCallback chain is the right move. In HttpComponents 5, RequestConfig.responseTimeout is the per-request read-timeout equivalent of HC4's socketTimeout. The SSL branch already sets ConnectionConfig.socketTimeout at the connection-manager level; the two operate at different layers and are complementary. Non-SSL connections now have the same timeout protection as SSL ones.
Fix 2 — AuthScope match-all: new AuthScope(null, null, -1, null, null) is the HC5 idiom for what HC4 exposed as AuthScope.ANY (removed in HC5). Scoping credentials to hostAddressesList.get(0) was a real bug in multi-node clusters — requests routed to other nodes would get 401. This is a direct port of what camel-elasticsearch already does with AuthScope.ANY.
Test coverage: No unit test is added, and that's acceptable here. createClient() produces an opaque RestClient via internal callbacks — the credential scope and timeout values aren't observable without a live cluster. The existing integration tests exercise the runtime path.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 9 tested, 27 compile-only — current: 9 all testedMaveniverse Scalpel detected 36 affected modules (current approach: 9).
|
| Module | Duration | Status |
|---|---|---|
| Camel :: Launcher | 49.7s | SUCCESS |
| Camel :: JBang :: MCP | 38.0s | SUCCESS |
| Camel :: JBang :: Plugin :: TUI | 31.9s | SUCCESS |
| Camel :: Catalog :: Camel Catalog | 21.8s | SUCCESS |
| Camel :: Component DSL | 21.2s | SUCCESS |
| Camel :: Docs | 14.3s | SUCCESS |
| Camel :: JBang :: Plugin :: Kubernetes | 14.2s | SUCCESS |
| Camel :: Catalog :: Camel Report Maven Plugin | 9.3s | SUCCESS |
| Camel :: YAML DSL :: Validator | 9.0s | SUCCESS |
| Camel :: Kamelet Main | 8.8s | SUCCESS |
| Camel :: Catalog :: Camel Route Parser | 8.4s | SUCCESS |
| Camel :: JBang :: Plugin :: Testing | 7.7s | SUCCESS |
| Camel :: YAML DSL :: Deserializers | 6.0s | SUCCESS |
| Camel :: All Components Sync point | 5.2s | SUCCESS |
| Camel :: JBang :: Plugin :: Validate | 4.6s | SUCCESS |
| Camel :: YAML DSL :: Validator Maven Plugin | 4.3s | SUCCESS |
| Camel :: YAML DSL :: Maven Plugins | 3.6s | SUCCESS |
| Camel :: Catalog :: Maven | 2.7s | SUCCESS |
| Camel :: Catalog :: Suggest (deprecated) | 2.5s | SUCCESS |
| Camel :: Assembly | 1.9s | SUCCESS |
| Camel :: JBang :: Plugin :: Edit | 1.9s | SUCCESS |
| Camel :: Coverage | 1.7s | SUCCESS |
| Camel :: JBang :: Integration tests | 1.1s | SUCCESS |
| Camel :: JBang :: Plugin :: Generate | 1.1s | SUCCESS |
| Camel :: Catalog :: Dummy Component | 1.1s | SUCCESS |
| Camel :: Endpoint DSL :: Support | 1.0s | SUCCESS |
| Camel :: JBang :: Plugin :: MCP | 0.9s | SUCCESS |
| Camel :: Catalog :: Console | 0.8s | SUCCESS |
| Camel :: JBang :: Main | 0.8s | SUCCESS |
| Camel :: Launcher :: Container | 0.7s | SUCCESS |
| Camel :: JBang :: Plugin :: Route Parser | 0.5s | SUCCESS |
| Camel :: Endpoint DSL | n/a | |
| Camel :: Integration Tests | n/a | |
| Camel :: JBang :: Core | n/a | |
| Camel :: OpenSearch Java API Client | n/a | |
| Camel :: YAML DSL | n/a |
Top 20 slowest modules:
Camel :: Launcher(49.7s)Camel :: JBang :: MCP(38.0s)Camel :: JBang :: Plugin :: TUI(31.9s)Camel :: Catalog :: Camel Catalog(21.8s)Camel :: Component DSL(21.2s)Camel :: Docs(14.3s)Camel :: JBang :: Plugin :: Kubernetes(14.2s)Camel :: Catalog :: Camel Report Maven Plugin(9.3s)Camel :: YAML DSL :: Validator(9.0s)Camel :: Kamelet Main(8.8s)Camel :: Catalog :: Camel Route Parser(8.4s)Camel :: JBang :: Plugin :: Testing(7.7s)Camel :: YAML DSL :: Deserializers(6.0s)Camel :: All Components Sync point(5.2s)Camel :: JBang :: Plugin :: Validate(4.6s)Camel :: YAML DSL :: Validator Maven Plugin(4.3s)Camel :: YAML DSL :: Maven Plugins(3.6s)Camel :: Catalog :: Maven(2.7s)Camel :: Catalog :: Suggest (deprecated)(2.5s)Camel :: Assembly(1.9s)
What
Two divergences in
OpensearchProducer.createClient()versus thecamel-elasticsearchproducer, both affecting real deployments.1.
socketTimeoutignored without SSLThe request-config callback set only
setConnectTimeout(...). ThesocketTimeoutoption was applied only inside theif (configuration.isEnableSSL())branch (through the pooling connection manager'sConnectionConfig). So on a plain-HTTP OpenSearch endpoint the configuredsocketTimeouthad no effect and a slow/stalled node could block the calling thread indefinitely.camel-elasticsearchapplies both connect and socket timeouts unconditionally.2. Basic-auth scoped to the first host only
Credentials were registered with
new AuthScope(hostAddressesList.get(0)), binding them to the first configured host/port. In a multi-host cluster, requests routed to any other node carried no credentials and were rejected with HTTP 401.camel-elasticsearchusesAuthScope.ANY(match all).Fix
setResponseTimeout(...)to the request-config callback so the read timeout is honoured for both plain-HTTP and SSL connections (HttpClient 5 equivalent of the socket timeout).AuthScope(null, null, -1, null, null)(the HttpClient 5 idiom, sinceAuthScope.ANYwas removed) so basic auth reaches every node.Testing
No new unit test:
createClient()configures the low-levelRestClient's callbacks, and the resulting credential/timeout config is not observable without a live multi-host / authenticated cluster (integration-only). The change makescamel-opensearchmatch the behaviour already implemented incamel-elasticsearch, and is exercised by the existing OpenSearch integration tests. Verified the module compiles and its unit tests pass.Notes
@UriParam/ generated-catalog change.camel-4.22.xandcamel-4.18.x.Generated by Claude Code on behalf of Andrea Cosentino (@oscerd).
🤖 Generated with Claude Code