shashank created CAMEL-27353:
--------------------------------

             Summary: camel-kubernetes - a stopped cluster view closes the 
KubernetesClient set on the configuration, which the other views and the user 
still use
                 Key: CAMEL-27353
                 URL: https://issues.apache.org/jira/browse/CAMEL-27353
             Project: Camel
          Issue Type: Bug
          Components: camel-kubernetes
            Reporter: shashank
            Assignee: shashank


h3. What happens

{{KubernetesClusterView.doStart}} takes its client from 
{{KubernetesHelper.getKubernetesClient(configuration)}}: the client set with 
{{KubernetesConfiguration.setKubernetesClient}} if there is one, otherwise a 
client it creates. {{doStop}} always closes that client. A client set on the 
configuration belongs to the user, and {{KubernetesClusterService.createView}} 
copies the configuration for each view, so all the views (groups) of the 
service share it. When one view stops (its last clustered route is removed, its 
{{MasterConsumer}} stops, or it is stopped through JMX), it closes the client 
of all the others:

* the other groups of the pod can no longer read or renew their lease 
({{IllegalStateException: Client is closed}}), lose the leadership locally once 
the renew deadline has passed, and cannot take it again; as the lease still 
names the pod and the pod is ready, no other pod leads these groups either, 
until the pod becomes unready;
* a view that is used again (the clustered route added again) starts on the 
closed client and never leads again;
* any other code of the user that uses the client fails.

{{AbstractKubernetesEndpoint.doStop}} already closes the client only when it is 
not set on the configuration, and the reload trigger tasks only close a client 
that was not autowired (CAMEL-21770).

This came up in the review of CAMEL-27296.

h3. How to reproduce

One {{KubernetesClusterService}} with 
{{KubernetesConfiguration.setKubernetesClient(client)}} and two groups led by 
the pod. Stop the view of the first group (release it as its last user does): 
the second group loses its leadership within the renew deadline, and the client 
throws {{Client is closed}}. Stop a view and get it again: it never becomes 
leader again.

Found with a TLA+ model of the views and their clients.

h3. Fix

The view remembers whether it created its client (no client set on the 
configuration) and closes only that one when it stops.

_Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to