grpc-ecosystem / grpc-spring

Spring Boot starter module for gRPC framework.
https://grpc-ecosystem.github.io/grpc-spring/
Apache License 2.0
3.46k stars 812 forks source link

Application fails to start on GrpcChannelProperties #979

Closed kjthorpe18 closed 10 months ago

kjthorpe18 commented 10 months ago

The context

Moving to version 2.15 from 2.14 to support an application on Spring Boot 3.1 with autoconfiguration. This application is a gRPC server, NOT a client.

grpc.server.port=6565

grpc.server.security.enabled=true
grpc.server.security.certificate-chain=%{GRPC_SERVER_CERT}
grpc.server.security.private-key=%{GRPC_SERVER_KEY}
grpc.server.security.trust-cert-collection=%{GRPC_CLIENT_KEY}
grpc.server.security.client-auth=REQUIRE
grpc.server.reflection-service-enabled=true

EDIT: added env vars and their use in the application properties. Environment variables set:

export GRPC_CA_CERT="file:/opt/grpc/cert/grpc_ca_cert.crt"
export GRPC_CLIENT_CERT="file:/opt/grpc/cert/grpc_client_cert.crt"
export GRPC_CLIENT_KEY="file:/opt/grpc/cert/grpc_client_key.pem"
export GRPC_SERVER_CERT="file:/opt/grpc/cert/grpc_server_cert.crt"
export GRPC_SERVER_KEY="file:/opt/grpc/cert/grpc_server_key.pem"

The bug

The application fails to start, possibly because grpc.client.* application properties are not defined, but this is not a grpc client. I do not have client properties set. Possibly this is due to the 2.15 auto configuration changes?

Stacktrace and logs

APPLICATION FAILED TO START\n***************************
Description:\n\nFailed to bind properties under 'grpc.client.cert' to net.devh.boot.grpc.client.config.GrpcChannelProperties:
Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [net.devh.boot.grpc.client.config.GrpcChannelProperties]
Action:
pdate your application's configuration

The application's environment

Which versions do you use?

ST-DDT commented 10 months ago

Is it possible that you have an environment variable (e.g. from kubernetes) that is GRPC_CLIENT_CERT? Also maybe you don't want to ship the client lib, if you don't plan to use it.

kjthorpe18 commented 10 months ago

Ah I think it does have that variable. It has a shared environment variable file with other applications, and has GRPC_CLIENT_CERT, GRPC_SERVER_CERT, etc. defined with a file path like export GRPC_CLIENT_CERT="file:/opt/grpc/cert/grpc_client_cert.crt". But, still not sure why this would be picked up the way it is in the error?

And yeah, I have the client auto configs it excluded from the main application context now, but need them for integration tests, so I'm including them there.

kjthorpe18 commented 10 months ago

I think I have two issues here: