Reason/Context
MongoDB Atlas imposes a connection to its service using a mongodb+srv:// prefixed URL. However, as of today, we impose a hard-coded value of mongodb:// in the SPRING_DATA_MONGODB_URI deployment environment variable.
This results in a badly shaped URL when using the URI provided by Atlas. Putting the hostname + 443 port only doesn't work either, as the driver detects it's a cluster and expects to retrieve additional shard names using SRV records.
Description
We need a way to connect to a Mongo SRV compatible cluster from the Helm chart installation.
Implementation ideas
Turning mongodb:// prefix into mongodb+srv:// doesn't work with our default provided database. First error is that a port must not be provided in srv mode, and if we remove the port, we get this one:
com.mongodb.MongoConfigurationException: Failed looking up SRV record for '_mongodb._tcp.microcks-mongodb'.
at com.mongodb.internal.dns.DefaultDnsResolver.resolveHostFromSrvRecords(DefaultDnsResolver.java:108)
at com.mongodb.internal.connection.DefaultDnsSrvRecordMonitor$DnsSrvRecordMonitorRunnable.run(DefaultDnsSrvRecordMonitor.java:80)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: com.mongodb.spi.dns.DnsWithResponseCodeException: DNS name not found [response code 3]
at com.mongodb.internal.dns.JndiDnsClient.getResourceRecordData(JndiDnsClient.java:55)
at com.mongodb.internal.dns.DefaultDnsResolver.resolveHostFromSrvRecords(DefaultDnsResolver.java:84)
... 2 common frames omitted
Caused by: javax.naming.NameNotFoundException: DNS name not found [response code 3]
at jdk.naming.dns/com.sun.jndi.dns.DnsClient.checkResponseCode(DnsClient.java:785)
at jdk.naming.dns/com.sun.jndi.dns.DnsClient.isMatchResponse(DnsClient.java:703)
Looks like we need to completely review how we build the SPRING_DATA_MONGODB_URI
Reason/Context
MongoDB Atlas imposes a connection to its service using a
mongodb+srv://prefixed URL. However, as of today, we impose a hard-coded value ofmongodb://in theSPRING_DATA_MONGODB_URIdeployment environment variable.This results in a badly shaped URL when using the URI provided by Atlas. Putting the hostname + 443 port only doesn't work either, as the driver detects it's a cluster and expects to retrieve additional shard names using
SRVrecords.Description
We need a way to connect to a Mongo SRV compatible cluster from the Helm chart installation.
Implementation ideas
Turning
mongodb://prefix intomongodb+srv://doesn't work with our default provided database. First error is that a port must not be provided insrvmode, and if we remove the port, we get this one:Looks like we need to completely review how we build the
SPRING_DATA_MONGODB_URI