-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
MongoHealthIndicator
uses isMaster
command, which is not part of Mongo's stable API https://www.mongodb.com/docs/v5.0/reference/stable-api-changelog/
If the underlying Mongo connection is configured to use the stable API and strict setting, the health indicator yields an error, as Mongo rejects the isMaster
command.
Affected versions: Tested with sprinboot 3.3.0, potentially since 3.0.0
To reproduce it, create a blank springboot project including spring-boot-starter-data-mongodb
, spring-boot-starter-web
and spring-boot-starter-actuator
dependencies. Then, set up both Mongo stable API version and strict
to true
by creating the following bean:
@Bean
public MongoClientSettings mongoClientSettings() {
return MongoClientSettings.builder()
.applicationName("testApp")
.serverApi(ServerApi.builder()
.strict(true)
.version(ServerApiVersion.V1)
.build())
.build();
}
For reference, such project has been created here https://github.com/jorgelc/mongo-stable-api-springboot-health, with steps about how to reproduced the error and compare the behaviour with when strict
is set to false.