allthingssecurity opened a new pull request, #27158: URL: https://github.com/apache/camel/pull/27158
# Description [CAMEL-25209](https://issues.apache.org/jira/browse/CAMEL-25209) `KubernetesLeadershipController` runs the leader election as a chain of tasks on a single-thread executor, each run scheduling the next one. All Kubernetes calls in it catch their exceptions, except the Lease renewal in the LEADER state (`refreshLeaseRenewTime`, a PUT with the resource version, used with the default `Lease` resource type). When that PUT failed (an API server outage longer than the client's own retries of 429/5xx/I/O errors, or an error that is not retried such as a 409 conflict), the exception ended the task, the next run was never scheduled, and nothing was logged. The leader then stopped refreshing its local leadership, so after the renew deadline it reported "no leader" and stopped its master routes, while the other pods kept seeing the Lease held by a running and ready pod (`LeaderInfo.hasValidLeader()` does not look at `renewTime`) and never took over. No pod led until the former leader pod was restarted. This change: `refreshStatus()` catches an exception, logs a WARN (the stack trace at DEBUG) and schedules the next run after the retry period, like the other failure paths. After `stop()` it only logs at DEBUG. Test: `KubernetesClusterServiceTest.testLeaderKeepsLeadershipAfterFailedLeaseRenewal` (Lease type, two pods): the leader's mock server refuses Lease updates until one renewal failed, then accepts them again; both pods must keep seeing the same leader. `LockTestServer` gets an option to refuse only the update (PUT) requests. Without the change the leader's recorder reports `null` after the renew deadline and the test fails. I ran the camel-kubernetes unit tests (146 pass, 6 skipped), and `KubernetesClusterServiceTest` and `TimedLeaderNotifierTest` again after the last change (26 pass). # 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]
