[
https://issues.apache.org/jira/browse/CAMEL-27488?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
shashank updated CAMEL-27488:
-----------------------------
Fix Version/s: 4.25.0
> camel-aws-secrets-manager, camel-hashicorp-vault - a failed reload after a
> secret update is never tried again, and the routes that did not start stay
> stopped
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27488
> URL: https://issues.apache.org/jira/browse/CAMEL-27488
> Project: Camel
> Issue Type: Bug
> Components: camel-aws2, camel-hashicorp-vault
> Reporter: shashank
> Assignee: shashank
> Priority: Major
> Fix For: 4.25.0
>
>
> h3. What happens
> The secret refresh tasks mark an update as seen before they reload the
> CamelContext:
> * {{CloudTrailReloadTriggerTask}} (CloudTrail mode) moves {{lastTime}} and
> adds the event ids to {{seenEventIds}}; in SQS mode it deletes the
> notification from the queue;
> * {{HashicorpVaultReloadTriggerTask}} stores the new version in
> {{versionsMap}}.
> Then they call {{ContextReloadStrategy.onReload(this)}}.
> {{DefaultContextReloadStrategy.onReload}} catches every exception: it counts
> a failed reload, logs a WARN and emits an event, and the task never learns
> that the reload failed. The next check finds nothing new, so nothing reloads
> again.
> A reload removes all the routes first and then starts them again from their
> definitions. With the default route controller, when one route fails to start
> during the reload (its broker is briefly unreachable, or a placeholder lookup
> fails), that route stays stopped and the routes after it are not added back,
> until the next update of a secret, a manual reload or a restart. (The
> supervising route controller starts such a route again by itself, and the
> reload counts as succeeded.)
> h3. How to reproduce
> A route whose consumer fails to start once, a
> {{DefaultContextReloadStrategy}}, and the HashiCorp task against a fake Vault
> (KV v2 metadata and data endpoints):
> # the route starts with version 1 of the secret;
> # the secret moves to version 2, and the consumer start fails once: the
> task's check reloads, the reload fails ({{failed=1}}), the route is Stopped;
> # 5 more checks: no reload ({{succeeded=0}}), the route is still Stopped and
> never ran with version 2.
> The CloudTrail task behaves the same with a mocked {{CloudTrailClient}} that
> returns one {{PutSecretValue}} event.
> Found with a TLA+ model of the refresh tasks, the shared periodic task thread
> and the context reload: the property "every update observed is eventually
> applied by a successful reload" fails on the current code and holds when the
> update is marked as seen only after a successful reload.
> h3. Fix
> The tasks mark an update as seen only once the reload succeeded: the
> CloudTrail task commits {{lastTime}} and the new event ids after it, the SQS
> mode deletes the notification of a matching update after it (other messages
> are still deleted at once, so the queue is still drained, see CAMEL-24193),
> the HashiCorp task stores the new versions after it. The task tells a failed
> reload from the reload strategy's failed counter
> ({{ReloadStrategy.getFailedCounter()}}, read before and after the reload, as
> {{ReloadDevConsole}} does), so the public API does not change; a reload from
> another source that fails meanwhile also counts, which costs one more reload.
> After a failed reload the next check sees the update again and reloads again,
> with a WARN each time, at most 10 times in a row; after that the update is
> marked as seen and the task waits for the next update. In SQS mode the retry
> comes when the queue delivers the notification again (after its visibility
> timeout, unless a redrive policy moves it to a dead-letter queue first).
> Not changed here: {{lastCheckTime}} and {{lastReloadTime}} are still set
> before the check and before the reload, so the dev console shows a check or a
> reload that failed as done (low). The GCP, Azure, IBM, Kubernetes and Spring
> Cloud Config refresh tasks also ignore whether the reload succeeded; they are
> left for a follow-up.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)