[ 
https://issues.apache.org/jira/browse/CAMEL-27315?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-27315 started by shashank.
----------------------------------------
> camel-kubernetes - a lease holder that is not ready gives up the leadership 
> and then reports itself as leader again on every poll
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27315
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27315
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-kubernetes
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>
> h3. What happens
> When the leader pod is no longer ready but still runs, 
> {{KubernetesLeadershipController.refreshStatusLeader}} moves it to NOT_LEADER 
> and publishes "no leader". The next {{refreshStatusNotLeader}} run reads the 
> lease, which still names the pod: the holder is not valid (not ready), 
> {{tryAcquireLeadership}} fails (the pod itself is not ready), and the run 
> ends with 
> {{leaderNotifier.refreshLeadership(Optional.ofNullable(latestLeaderInfo.getLeader()),
>  now, leaseDuration, ...)}}, which publishes the pod itself as leader for the 
> lease duration.
> So the pod reports leader, no leader, leader again (the clustered routes stop 
> and start again), on every poll while it is not ready and holds the lease, 
> without the BECOMING_LEADER wait. The claim lasts the lease duration after 
> the last read instead of the renew deadline: if another ready pod takes the 
> lease during this pod's request for the pod list, and this pod then cannot 
> reach the API server, both pods report themselves as leader for about the 
> duration of that request.
> h3. How to reproduce
> {{KubernetesNotReadyLeaseHolderTest}} (camel-kubernetes, {{LockTestServer}}, 
> Lease and ConfigMap): make the pods not ready; the leader gives up the 
> leadership and reports itself as leader again a retry period later.
> Found with a TLA+ model of the lease leader election.
> h3. Fix
> {{refreshStatusNotLeader}} does not publish the local pod as leader (it can 
> only be the holder there when it is not a valid leader): it publishes "no 
> leader" instead. Builds on CAMEL-27296 (same class).
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to