allthingssecurity opened a new pull request, #30353:
URL: https://github.com/apache/camel/pull/30353

   # Description
   
   [CAMEL-27170](https://issues.apache.org/jira/browse/CAMEL-27170)
   
   `DefaultSupervisingRouteController` overrides `startRoute`, `stopRoute`, 
`suspendRoute` and `resumeRoute`: each releases the route from the route 
manager (cancels its back-off restart task, clears its exhausted state and last 
restart error) and marks the route as managed by the controller or not. 
`startRouteGroup` and `stopRouteGroup` are not overridden, so they go straight 
to `AbstractCamelContext` and skip all of that:
   
   - `stopRouteGroup`: a route of the group that failed to start and waits for 
its next restart attempt is not in the started routes, so the group stop does 
not touch it, and its restart task keeps running. Once the cause is gone (the 
broker is back), the task starts the route, although the operator stopped its 
group. `stopRoute` of the same route keeps it stopped (CAMEL-25010).
   - `startRouteGroup`: a route whose restarts were exhausted runs again, but 
stays in the exhausted routes, so with `unhealthyOnExhausted=true` the route 
controller health check stays DOWN for good. `startRoute` clears it 
(CAMEL-25001).
   - `startRouteGroup`: a route that fails to start is not handed to the 
supervisor, so it is never restarted. `startRoute` hands it over.
   
   Route groups are started and stopped through JMX (`ManagedRouteGroup`), the 
developer console and the Camel CLI.
   
   Fix: the supervising route controller overrides `startRouteGroup` and 
`stopRouteGroup`. Under the controller lock it does for each route of the group 
what `startRoute` / `stopRoute` do (release the route, set or clear its route 
controller), then calls the group operation of the context; when the group 
start fails, the routes of the group that are still stopped are moved to the 
supervisor, as `startRoute` does for its route. The lock order is the one of 
`doStartRoute` / `doStopRoute` (controller lock, then the context lock), and a 
restart attempt checks under the same controller lock that its task is still 
the route's task, so an attempt cannot start a route after the group stop 
released it.
   
   Model: a small TLA+ model (`SupGroup.tla`: one supervised route, its 
back-off task, the four manual operations, a failing / fixed consumer) checks 
"a route the operator stopped is not started by anything else", "a started 
route is not exhausted" and "a route the operator started is running or 
supervised". On main each of the three is violated (traces of 3 to 5 states; 
the first: the cause is fixed, the group is stopped, the restart attempt starts 
the route); with the overrides all three hold (43 distinct states, up to 4 
manual operations and 2 restart attempts).
   
   Tests: `DefaultSupervisingRouteControllerRouteGroupTest` (three tests, one 
per item above). On main all three fail (the restart task is still there after 
the group stop; the route stays exhausted; no restart task after the failed 
group start); with the change they pass, and the supervising, route group and 
route controller tests of camel-core pass (31 run, 0 failures). The new class 
20 times in one JVM: 60 run, 0 failures.
   
   Not changed (follow-up if wanted): `AbstractCamelContext.startRouteGroup` 
iterates the route services without the context lock and does not reset the 
last route error, which `stopRouteGroup` does.
   
   # 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-27170](https://issues.apache.org/jira/browse/CAMEL-27170).
   
   # 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 the touched modules with the formatter and import-sort plugins; 
no option, doc or generated file changes. I did not run the full root build.)
   
   # 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]

Reply via email to