Discovery on all namespaces leads to NullPointerException on service
See original GitHub issueFor a bit of backstory: I’m trying out the new spring.cloud.kubernetes.discovery.all-namespaces=true
to retrieve service instances on all namespaces within a single instance of Spring Boot Admin. This seems to work fine if, and only if, all matching services are deployed to all namespaces. If any service is missing on any namespace, I get the following stacktrace:
java.lang.NullPointerException: null
at org.springframework.cloud.kubernetes.discovery.KubernetesDiscoveryClient.getInstances(KubernetesDiscoveryClient.java:122)
at org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient.getInstances(CompositeDiscoveryClient.java:53)
at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.drainSync(FluxFlattenIterable.java:519)
at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.drain(FluxFlattenIterable.java:633)
at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.request(FluxFlattenIterable.java:267)
at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.request(FluxFilterFuseable.java:184)
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:332)
at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onSubscribe(FluxFilterFuseable.java:81)
at reactor.core.publisher.FluxFlattenIterable$FlattenIterableSubscriber.onSubscribe(FluxFlattenIterable.java:209)
at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onSubscribe(FluxFilterFuseable.java:81)
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:135)
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63)
at reactor.core.publisher.Mono.subscribe(Mono.java:3920)
at reactor.core.publisher.Mono.subscribeWith(Mono.java:4030)
at reactor.core.publisher.Mono.subscribe(Mono.java:3899)
at reactor.core.publisher.Mono.subscribe(Mono.java:3835)
at reactor.core.publisher.Mono.subscribe(Mono.java:3807)
at de.codecentric.boot.admin.server.cloud.discovery.InstanceDiscoveryListener.discover(InstanceDiscoveryListener.java:124)
at de.codecentric.boot.admin.server.cloud.discovery.InstanceDiscoveryListener.onApplicationReady(InstanceDiscoveryListener.java:91)
Tracing through the code this happens when service
is null in this line: https://github.com/spring-cloud/spring-cloud-kubernetes/blob/702c7b2ee83291b71ede94a4862d364cfa6284b6/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java#L122
So while that service might be available on other namespaces, it’s not on the particular namespace queried, leading to null & NPE. Can this be fixed somehow?
My application is pretty minimal; just the most recent snapshots of SBA & SCK8S with the following configuration:
spring.boot.admin.discovery.converter.management-context-path: /
spring.cloud.kubernetes.discovery.all-namespaces: true
spring.cloud.kubernetes.discovery.filter: metadata.name.startsWith('some-prefix')
spring.cloud.kubernetes.discovery.primaryPortName: management
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
yes, this is the same issue I encountered with #465.
@michaelmcfadyen thanks for confirming and exploring I’m more depth in your ticket… guess that makes this a duplicate that we can close while we wait for the other ticket to be resolved.