Skip to content

Conversation

wind57
Copy link
Contributor

@wind57 wind57 commented May 28, 2024

No description provided.

wind57 added 30 commits April 19, 2023 16:45
@wind57
Copy link
Contributor Author

wind57 commented Jun 5, 2025

  • from the previous conversation, we agreed that since this is feature flag protected (and we do not drop the previous implementation) it does not need a major
  • DCO is is going to be a pain, since I've started this work a lot before we had DCO in place. If you say its a must-have, I will close this one and create a new PR, but it will take a while

@@ -44,7 +44,7 @@
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(LeaderProperties.class)
@ConditionalOnBean(KubernetesClient.class)
@ConditionalOnProperty(value = "spring.cloud.kubernetes.leader.enabled", matchIfMissing = true)
@ConditionalOnLeaderElectionDisabled
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tagging you in here also @ryanjbaxter because I need an opinion.

So before we made this change, you could disable leader election via :

spring.cloud.kubernetes.leader.enabled=false

So you would get this dependency and for whatever reason, if you wanted to disable leader election, you could. Now, we are taking away this option from users and they are essentially left with two options only:

  • use the previous implementation (via spring.cloud.kubernetes.leader.election.enabled=false)
  • use the new implementation (via spring.cloud.kubernetes.leader.election.enabled=true)

There are two things out of this: 1) there is no way to opt-out of leader election now; though it is weird to have the dependency on your classpath and still disable it 2) this can easily be seen as a breaking change...

Let me know if you need more details or this is clear for you. We can't this one merged until we are both on par. Thank you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the leader election functionality is still present but the underlying implementation changes, I think we can just remove the old implementation. Of course that means that this would only go in a major then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually wanted to keep both implementations :

  • the old stays intact and works the same as it used to
  • you can opt-in into the new one

The reason for this is that this I would like to users to be able to "test" the new functionality and raise any issues/concerns they have, but at the same time have a safe fallback.

If you agree, I will change the flags a bit to support this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK and it needs to be documented

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its already documented:

There is another way you can configure leader election, and it comes with native support in the fabric8 library (k8s native client support is not yet implemented). In the long run, this will be the default way to configure leader election, while the previous one will be dropped. You can treat this one much like the JDKs "preview" features.

To be able to use it, you need to set the property:

[source]
----
spring.cloud.kubernetes.leader.election.enabled=true
----

I've added tests and left the old implementation intact.

This is finally ready to go imo.

@wind57 wind57 requested a review from ryanjbaxter June 16, 2025 20:51
@ryanjbaxter ryanjbaxter linked an issue Jul 28, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do we have support for Lease based leader access. Spring Cloud Kubernetes - Use Informers instead of Watchers
4 participants