[
https://issues.apache.org/jira/browse/CAMEL-27585?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-27585.
---------------------------------
Resolution: Fixed
Fixed by https://github.com/apache/camel/pull/30907 (merged as 579f416f33ee),
in 4.24.0.
_Claude Code on behalf of Claus Ibsen_
> camel-kubernetes - a cluster view stopped while it takes an empty lease
> leaves the lease naming its pod, so no other pod leads while that pod stays
> ready
> ---------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27585
> URL: https://issues.apache.org/jira/browse/CAMEL-27585
> Project: Camel
> Issue Type: Bug
> Components: camel-kubernetes
> Reporter: shashank
> Assignee: shashank
> Priority: Major
> Fix For: 4.24.0
>
>
> h3. What happens
> CAMEL-27296 made a stopped {{KubernetesClusterView}} give up the lease. The
> release is only done when the leadership of the pod has taken effect
> ({{LEADER}}, {{LOSING_LEADERSHIP}}, {{LEADERSHIP_LOST}}). Two cases are left
> out where the pod is not leader but the lease names it:
> # The pod finds the lease empty (or absent) and sends the request that takes
> it with immediate effect. The API server applies it, and the view is stopped
> before the answer arrives. The stop interrupts the refresh, the request fails
> on the client side ("Unable to update the lock lease resource to set
> leadership information" or "Unable to create the lease resource"), and the
> controller stays {{NOT_LEADER}}. {{releaseLeadership}} returns at once, as
> the leadership "has not taken effect". The lease now names the stopped view.
> # The leader is not ready for a moment, so its next refresh moves it to
> {{NOT_LEADER}} without touching the lease (it still names the pod). The view
> is stopped in that window, and {{releaseLeadership}} returns at once again.
> When the pod is ready again before another pod took over, the lease names the
> stopped view.
> In both cases every other pod sees a valid holder (a ready pod) and only
> reports it, so the group has no leader for as long as the pod stays ready.
> That is unbounded when only the view stops (the last clustered route or
> master consumer of the group is stopped or removed) and the rest of the pod
> keeps running. An empty lease is common right after another pod released it
> at its stop, so case 1 fits rolling restarts. Case 2 needs a readiness flap
> shorter than the retry period of the other pods, so it is rare.
> The pod never acted as leader in case 1 and no longer acts as leader in case
> 2, so releasing the lease is safe: there is no previous leader for another
> pod to wait for.
> h3. How to reproduce
> The module's {{LockTestServer}} applies a write when it arrives and can
> answer after a delay. Two pods, the second cannot reach the API server at
> first. The first pod takes the empty lease, the server answers it after 1 s,
> and the view of the first pod is stopped as soon as the lease names it. The
> lease keeps naming the first pod, and the second pod (once it reaches the API
> server) reports the first pod as leader and never leads. Same for case 2 with
> the first pod taken out of the ready pods while the second pod cannot reach
> the API server.
> Found with a TLA+ model of the leadership controller and its stop (liveness:
> some ready pod eventually leads).
> h3. Fix
> The controller remembers that a request to take an empty lease was sent and
> has not succeeded (cleared by the next successful lookup).
> {{releaseLeadership}} also releases from {{NOT_LEADER}} when that flag is set
> or when the last lookup found the lease naming this pod. The release reads
> the lease and removes the pod only if the lease names it, as before.
> Not covered: a stop whose wait for the running refresh times out (the request
> is still on the wire), which is the documented "no time left" case, a stop in
> {{BECOMING_LEADER}} (kept on purpose), and an interrupted acquisition that
> the API server still applies after the release read the lease (the client
> does not cancel the request; closing this needs a fencing write and is left
> for a later change).
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)