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

Discovery Service Filter not working #3

Open
tcarlson25 opened this issue Nov 15, 2019 · 4 comments
Open

Discovery Service Filter not working #3

tcarlson25 opened this issue Nov 15, 2019 · 4 comments

Comments

@tcarlson25
Copy link

tcarlson25 commented Nov 15, 2019

The gateway works fine when I don't add the discovery filter property, as it picks up all services in my cluster and creates routes to them. However, when I add the property:

spring:
    cloud:
        kubernetes:
            discovery:
                filter: "metadata.labels['s1p']"

and change my service that I want to picked up from the gateway to have a label in the metadata to have s1p: "true", nothing gets picked up and I get this error instead:

org.springframework.expression.spel.SpelEvaluationException: EL1012E: Cannot index into a null value

Any ideas on what I could be doing wrong?

@salaboy
Copy link
Owner

salaboy commented Nov 15, 2019

Did you checked the other examples of these demo? Just to make sure that your labels are matching.. also which version of spring cloud are you using.. it might be that the filters are broken..

@tcarlson25
Copy link
Author

Yeah I've looked at all the other examples. I'm using Greenwich.SR3, which pulls in spring-cloud-kubernetes: 1.0.3.RELEASE

@tcarlson25
Copy link
Author

Here is the full error. It actually shows up when the app starts up. So it doesn't even start completely..

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1012E: Cannot index into a null value
	at org.springframework.expression.spel.ast.Indexer.getValueRef(Indexer.java:144) ~[spring-expression-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:68) ~[spring-expression-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:89) ~[spring-expression-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:114) ~[spring-expression-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:365) ~[spring-expression-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.cloud.kubernetes.discovery.KubernetesDiscoveryClient.lambda$getServices$7(KubernetesDiscoveryClient.java:241) ~[spring-cloud-kubernetes-discovery-1.0.3.RELEASE.jar:1.0.3.RELEASE]
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) ~[na:1.8.0_212]
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[na:1.8.0_212]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[na:1.8.0_212]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[na:1.8.0_212]
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_212]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_212]
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_212]
	at org.springframework.cloud.kubernetes.discovery.KubernetesDiscoveryClient.getServices(KubernetesDiscoveryClient.java:255) ~[spring-cloud-kubernetes-discovery-1.0.3.RELEASE.jar:1.0.3.RELEASE]
	at org.springframework.cloud.kubernetes.discovery.KubernetesDiscoveryClient.getServices(KubernetesDiscoveryClient.java:249) ~[spring-cloud-kubernetes-discovery-1.0.3.RELEASE.jar:1.0.3.RELEASE]
	at org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient.getServices(CompositeDiscoveryClient.java:67) ~[spring-cloud-commons-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.cloud.gateway.discovery.DiscoveryClientRouteDefinitionLocator.getRouteDefinitions(DiscoveryClientRouteDefinitionLocator.java:96) ~[spring-cloud-gateway-core-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:350) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:243) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:201) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:335) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:139) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxFlatMap.subscribe(FluxFlatMap.java:97) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.Flux.subscribe(Flux.java:7799) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:389) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:243) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:201) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:335) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:139) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxFlatMap.subscribe(FluxFlatMap.java:97) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.MonoCollectList.subscribe(MonoCollectList.java:40) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.MonoFlattenIterable.subscribe(MonoFlattenIterable.java:101) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxMaterialize.subscribe(FluxMaterialize.java:40) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.MonoCollectList.subscribe(MonoCollectList.java:40) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.MonoFlattenIterable.subscribe(MonoFlattenIterable.java:101) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxDematerialize.subscribe(FluxDematerialize.java:39) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:54) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.Flux.subscribe(Flux.java:7799) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.Flux.subscribeWith(Flux.java:7963) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.Flux.subscribe(Flux.java:7792) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.Flux.subscribe(Flux.java:7756) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at reactor.core.publisher.Flux.subscribe(Flux.java:7674) ~[reactor-core-3.2.9.RELEASE.jar:3.2.9.RELEASE]
	at org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.lambda$onApplicationEvent$0(WeightCalculatorWebFilter.java:133) ~[spring-cloud-gateway-core-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.beans.factory.ObjectProvider.ifAvailable(ObjectProvider.java:93) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter.onApplicationEvent(WeightCalculatorWebFilter.java:133) ~[spring-cloud-gateway-core-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.cloud.gateway.route.RouteRefreshListener.reset(RouteRefreshListener.java:68) ~[spring-cloud-gateway-core-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.cloud.gateway.route.RouteRefreshListener.onApplicationEvent(RouteRefreshListener.java:49) ~[spring-cloud-gateway-core-2.1.3.RELEASE.jar:2.1.3.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.finishRefresh(ReactiveWebServerApplicationContext.java:121) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:67) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE]

@salaboy
Copy link
Owner

salaboy commented Nov 16, 2019

That was definitely not happening in my examples.. so it might be broken now with those versions.. Can you please create a simple project that reproduces the problem? Or even send a PR here updating to the versions that you are using so we can have a public project failing?

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

No branches or pull requests

2 participants