allthingssecurity opened a new pull request, #30826: URL: https://github.com/apache/camel/pull/30826
# Description [CAMEL-27490](https://issues.apache.org/jira/browse/CAMEL-27490) All the periodic tasks of a CamelContext run one after the other on one thread: `DefaultPeriodTaskScheduler` registers them with the context's `TimerListenerManager`, and `PeriodicTaskWrapper.onTimer` calls `task.run()` on its single timer thread. That thread runs the secret refresh tasks of every vault, and other tasks such as the Service Bus lock renewer. `CloudTrailReloadTriggerTask` built its `CloudTrailClient` and `SqsClient` without an override configuration, so their calls had no API call timeout: one call was bounded only by the socket timeout of the HTTP client and the SDK retries, and an answer that keeps coming slowly was not bounded at all. While `lookupEvents` or `receiveMessage` waited, no other periodic task of the context ran. In a test, a probe task with a period of 1 second went about 10 seconds without running while `lookupEvents` took 8 seconds. The Service Bus lock renewer runs on that thread too, so its message locks can expire during such a stall; I infer th at from its timing, I did not reproduce it. With SQS notification, a receive wait time (long polling) set on the queue also made each check wait on that thread, for up to 20 seconds, because the request did not set its own wait time. Change, in `CloudTrailReloadTriggerTask` only: - both clients get `ClientOverrideConfiguration.apiCallTimeout` of 10 seconds, which covers all attempts of one call. A call that times out throws, is logged by the existing catch ("Will try again on next run") and is tried again at the next check, as any other failed call; - the SQS receive sets `waitTimeSeconds(0)`: the check runs again after the refresh period anyway, so it does not need to wait for messages, and the queue's long polling setting can no longer hold the thread (or be cut by the timeout). A short receive can come back empty while a notification is already queued (SQS samples a subset of its servers), so such a notification can be read one check later. The 10 seconds are a constant, not an option, of the same order as the timeouts of the HashiCorp Vault task (5 seconds to connect, 15 to read, see the 4.24 guide). I can make it a `camel.vault.aws` option if reviewers want one. A check makes more than one call (two `LookupEvents` lookups, more pages), so a check can still take longer than 10 seconds when several calls are slow; each call is bounded. Docs: the component page says that the calls time out after 10 seconds and that the SQS receive does not wait; the catalog copy is regenerated. The 4.24 upgrade guide has a new section `camel-aws-secrets-manager - the calls of the refresh task time out`, because a call slower than 10 seconds now fails, and a queue's receive wait time is no longer used. Not changed here: - the scheduler itself: every periodic task of the context still runs on one thread, so other blocking work there remains a risk, such as the context reload that a refresh task triggers (it stops the routes gracefully, on that same thread) and the other periodic tasks; - a `VirtualMachineError` thrown by a periodic task still ends the timer thread, and with it every periodic task; `TimerListenerManager` keeps that on purpose (CAMEL-26906 handles the other errors); - the HashiCorp Vault task already has the Spring Vault timeouts (connect 5 s, read 15 s per secret); the GCP and Azure tasks were not checked for this here; - the refresh task still marks an update as seen before the reload, so a failed reload is not tried again; that is a separate ticket, CAMEL-27488 (#30814). Tests, new `CloudTrailReloadTriggerTaskCallTimeoutTest` (package-private; the real SDK clients against a local HTTP server that does not answer until the test ends, call timeout set to 500 ms through a package-private setter for tests; no sleep): - `lookupThatHangsEndsAfterTheCallTimeout`: a check in CloudTrail mode returns within 5 seconds; - `receiveThatHangsEndsAfterTheCallTimeout`: the same in SQS mode, and the receive request has a wait time of 0; - `lookupThatHangsDoesNotStallTheOtherPeriodicTasks`: with the refresh task and a probe task on the context's period task scheduler (period 1 second), the probe runs twice within 10 seconds after CloudTrail stopped answering. The test class uses the new setter, so it does not compile against the current task. The same three tests with the default timeout instead of the setter (and waits of 15 seconds) fail against the current task, 3 of 3 (the check is still waiting after 15 seconds, and the probe task does not run), and pass with the change. With the change, the camel-aws-secrets-manager unit tests pass (35 run, 0 failures), and the new class passes 20 of 20 runs. The ITs were not run locally (CI runs them). A TLA+ model of the refresh tasks and the shared periodic task thread found this: its invariant "every periodic task runs at least once per period plus a bounded call time" fails when a store call is slow (and holds when no call is slow). # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-27490](https://issues.apache.org/jira/browse/CAMEL-27490). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built camel-aws-secrets-manager and the core modules with the formatter and import-sort plugins and ran its unit tests. I did not run the full root build. The catalog copy of the component page is included.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
