allthingssecurity opened a new pull request, #27302: URL: https://github.com/apache/camel/pull/27302
# Description [CAMEL-25273](https://issues.apache.org/jira/browse/CAMEL-25273) The fabric8 client reconnects a watch by itself after transient errors, but closes it for good, calling `Watcher.onClose` with a `WatcherException`, when it gives up: when the API server answers 410 Gone because the resource version of the watch is too old (`AbstractWatchManager.onStatus`: "has to be handled by the caller"; this happens to long-running watches), or when the reconnect limit is reached. The watch consumers of camel-kubernetes only logged that exception: the route stayed started but received no event anymore. This change: `onClose` with an exception runs the watch task of the consumer again (`KubernetesHelper.watchAgain`, only while the consumer runs and its executor is up), in the 11 watch consumers (pods, services, deployments, config maps, custom resources, events, HPA, namespaces, nodes, replication controllers, OpenShift deployment configs). The new watch has no resource version, so it starts with the current state (`ADDED` for the existing resources, as when the route starts). A close without exception (the consumer closing its own watch on stop) is unchanged. Tests: - `KubernetesPodsConsumerWatchClosedTest` (new, fabric8 mock server): the first watch gets an `ERROR` event with a 410 `Status`, a second watch would get an `ADDED` pod. - Without the change it fails: the consumer logs "too old resource version" and never watches again, `mock://result Received message count. Expected: <1> but was: <0>`. - With the change all camel-kubernetes unit tests pass: 156 tests, 0 failures (the ITs need a cluster). # 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). # 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 and tested the affected module, including the formatter and import-sort plugins. 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]
