shashank created CAMEL-27318:
--------------------------------

             Summary: camel-kubernetes - each setDisabled change adds a chain 
of leadership refreshes, so the API server is polled more often after every 
rebalance
                 Key: CAMEL-27318
                 URL: https://issues.apache.org/jira/browse/CAMEL-27318
             Project: Camel
          Issue Type: Bug
          Components: camel-kubernetes
            Reporter: shashank
            Assignee: shashank


h3. What happens

{{KubernetesLeadershipController.setDisabled}} executes one more 
{{refreshStatus}} when the value changes. Every run of {{refreshStatus}} 
executes or schedules exactly one next run, so that extra run starts a second 
chain of refreshes that never ends: after N changes there are N+1 chains, and 
the pod reads the lease and the pod list N+1 times per retry period. 
{{RebalancingCamelClusterService}} calls {{setDisabled}} on the views of its 
partitions on every rebalance, so the load on the API server grows with each 
rebalance for as long as the application runs.

h3. How to reproduce

{{KubernetesLeadershipRefreshTest}} (camel-kubernetes, {{LockTestServer}}, 
Lease and ConfigMap): measure the time the follower takes for 20 requests to 
its API server, call {{setDisabled(true)}} and {{setDisabled(false)}} 5 times, 
and measure again: after the 10 changes there are 11 chains, and the 20 
requests took about 100 ms instead of about 2100 ms.

Found with a TLA+ model of the refresh loop.

h3. Fix

The refreshes carry the id of their chain. {{setDisabled}} starts a new chain 
at once (so the change is applied without waiting), and a run of an older chain 
ends without a next run. Builds on CAMEL-27315 (the not-ready lease holder fix, 
same class) and CAMEL-27296.

_Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to