Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining namespace explicitly is required after Spring Boot upgrade for leader election #1663

Closed
johanhaleby opened this issue Jun 12, 2024 · 2 comments

Comments

@johanhaleby
Copy link

We're using the leader election library (org.springframework.cloud:spring-cloud-kubernetes-fabric8-leader:3.1.2) but after upgrading from Spring Boot 3.2.6 to 3.3.0 we ran into this issue:

2024-06-12T05:44:19.774Z ERROR 1 --- [my-service] [           main] o.s.boot.SpringApplication               : Application run failed
[my-service-7bd888c6f7-w8js9]
org.springframework.context.ApplicationContextException: Failed to start bean 'leaderInitiator'
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:291)
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:471)
	at java.base/java.lang.Iterable.forEach(Unknown Source)
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:260)
	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:205)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:981)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
	at com.mycompany.BootstrapKt.main(Bootstrap.kt:19)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:91)
	at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53)
	at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:58)
Caused by: io.fabric8.kubernetes.client.KubernetesClientException: namespace cannot be null
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.inNamespace(BaseOperation.java:252)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.inNamespace(BaseOperation.java:97)
	at org.springframework.cloud.kubernetes.fabric8.leader.Fabric8LeaderRecordWatcher.lambda$start$1(Fabric8LeaderRecordWatcher.java:63)
	at org.springframework.cloud.kubernetes.commons.leader.LeaderUtils.guarded(LeaderUtils.java:51)
	at org.springframework.cloud.kubernetes.fabric8.leader.Fabric8LeaderRecordWatcher.start(Fabric8LeaderRecordWatcher.java:59)
	at org.springframework.cloud.kubernetes.commons.leader.LeaderInitiator.start(LeaderInitiator.java:62)
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:288)
	... 18 common frames omitted

What I had to do was to explicitly add the namespace property to the config:

spring:
  cloud:
    kubernetes:
      leader:
        namespace: default
        config-map-name: leader

I.e. it seems like the spring.cloud.kubernetes.leader.namespace property is now also a required property besides spring.cloud.kubernetes.leader.config-map-name. This is not clear in the documentation. I suspect that either this is a bug in the code or that something should be added to the documentation.

@johanhaleby johanhaleby changed the title Defining namespace explicitly is required after Spring Boot upgrade Defining namespace explicitly is required after Spring Boot upgrade of leader election Jun 12, 2024
@johanhaleby johanhaleby changed the title Defining namespace explicitly is required after Spring Boot upgrade of leader election Defining namespace explicitly is required after Spring Boot upgrade for leader election Jun 12, 2024
@wind57
Copy link
Contributor

wind57 commented Jun 12, 2024

Duplicate of : #1661

@johanhaleby
Copy link
Author

@wind57 You're right, missed it! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants