shashank created CAMEL-27494:
--------------------------------
Summary: camel-google-secret-manager - a Pub/Sub subscriber of the
secret refresh task that fails once is never started again, so later secret
rotations no longer reload the CamelContext
Key: CAMEL-27494
URL: https://issues.apache.org/jira/browse/CAMEL-27494
Project: Camel
Issue Type: Bug
Components: camel-google
Reporter: shashank
Assignee: shashank
h3. What happens
{{PubsubReloadTriggerTask}} receives the secret events of the GCP secret
refresh from a Google Pub/Sub {{Subscriber}} that it builds once, in
{{doStart}}. {{run()}} runs every refresh period on the timer thread that the
periodic tasks of the CamelContext share; it sets {{lastCheckTime}} and starts
the {{Subscriber}} only when its state is {{NEW}}.
A {{Subscriber}} whose streaming pull gets a status that it does not retry
({{PERMISSION_DENIED}} while an IAM binding propagates or is briefly removed,
{{NOT_FOUND}}) goes to {{FAILED}}, and a failed {{ApiService}} cannot be
started again. {{run()}} leaves it there for good: no secret event is received
any more, so no later secret rotation reloads the CamelContext until the
application is restarted. The failure is logged only at DEBUG (the
{{IllegalStateException}} of {{awaitRunning()}}, which the timer ignores), and
{{run()}} keeps setting {{lastCheckTime}}, so the dev console shows a recent
check while nothing listens.
h3. How to reproduce
The real {{Subscriber}} with the task's own receiver, against an in-process
fake of the Pub/Sub Subscriber service (gRPC), scheduled with the
CamelContext's period task scheduler: the fake refuses the first streaming pull
with {{PERMISSION_DENIED}}, then allows it and delivers one
{{SECRET_VERSION_ADD}} event of a watched secret. Result: the subscriber stays
{{FAILED}}, {{run()}} is called 17 times in 3 s and {{lastCheckTime}} moves
forward, no streaming pull is made once permitted, 0 reloads, nothing logged at
INFO or above. With the permission from the start the same setup gives 1 reload.
Found with a TLA+ model of the push-based vault refresh listeners and the
period task scheduler: "every rotation is eventually consumed while Camel runs"
fails after one subscriber failure.
h3. Fix
{{run()}} replaces a {{Subscriber}} that is {{FAILED}} (or {{TERMINATED}} while
the task is started) with a new one built the same way, and starts it: at most
one new subscriber per refresh. The first replacement in a row is logged at
WARN with the failure cause, repeats at DEBUG, and a subscriber that runs again
at INFO. A new subscriber reports running before the service answers its
streaming pull, so one that replaced a failed subscriber counts as running
(INFO, {{lastCheckTime}}) only when it still runs at the next refresh: while
the pull keeps being refused there is one WARN and the last check does not
move. {{awaitRunning()}} gets a deadline (5 s), so a start that hangs no longer
holds the shared timer thread and every other periodic task. {{lastCheckTime}}
is set only when the subscriber is running.
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)