Closed snahelou closed 4 years ago
hi @snahelou ,
I've tried with 1.25.12 and everything works fine.
my uri is mongodb+srv://xxx:xxx@xxx.xxx.mongodb.net/gravitee?retryWrites=true&w=majority
It's strange, everything works find with previous version.
In addition my DNS server works well
/opt/graviteeio-management-api $ dig SRV _mongodb._tcp.xx.xx.mongodb.net
; <<>> DiG 9.10.2 <<>> SRV _mongodb._tcp.xx.xx.mongodb.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2935
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;_mongodb._tcp.xx.xx.mongodb.net. IN SRV
;; ANSWER SECTION:
_mongodb._tcp.xx.xx.mongodb.net. 59 IN SRV 0 0 27017 xx-shard-00-00-xx.xx.mongodb.net.
_mongodb._tcp.xx.xx.mongodb.net. 59 IN SRV 0 0 27017 xx-shard-00-01-xx.xx.mongodb.net.
_mongodb._tcp.xx.xx.mongodb.net. 59 IN SRV 0 0 27017 xx-shard-00-02-xx.xx.mongodb.net.
@NicolasGeraud Did you tried on a cluster using multiple replicas?
I keep you in touch when I find something...
BR
EDIT:
Just tried at home:
docker run --env GRAVITEE_MANAGEMENT_MONGODB_URI="mongodb+srv://xx:xx@xx.xx.mongodb.net/gravitee?retryWrites=true&w=majority" graviteeio/management-api:latest
=========================================================================
Gravitee.IO Management Standalone Runtime Bootstrap Environment
GRAVITEE_HOME: /opt/graviteeio-management-api
GRAVITEE_OPTS:
JAVA: /usr/lib/jvm/java-1.8-openjdk/jre/bin/java
JAVA_OPTS: -Djava.net.preferIPv4Stack=true -Xms1024m -Xmx2048m -Djava.awt.headless=true -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8
CLASSPATH: /opt/graviteeio-management-api/lib/gravitee-management-api-standalone-bootstrap-1.29.5.jar
=========================================================================
16:58:08.241 [graviteeio-node] INFO i.g.m.r.p.RepositoryPluginHandler - Register a new repository: repository-mongodb [io.gravitee.repository.mongodb.MongoRepository]
16:58:08.242 [graviteeio-node] INFO i.g.m.r.p.RepositoryPluginHandler - Repository [MANAGEMENT] loaded by mongodb
....
16:58:12.824 [graviteeio-node] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoCommandRepository': Invocation of init method failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: Timed out after 1000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@27b490de. Client view of cluster state is {type=REPLICA_SET, servers=[{address=xx.xx.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: xx.xx.mongodb.net}, caused by {java.net.UnknownHostException: xx.xx.mongodb.net}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 1000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@27b490de. Client view of cluster state is {type=REPLICA_SET, servers=[{address=xx.xx.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: xx.xx.mongodb.net}, caused by {java.net.UnknownHostException: xx.xx.mongodb.net}}]
16:58:12.832 [graviteeio-node] ERROR i.g.p.c.i.PluginContextFactoryImpl - Unable to refresh plugin context
It works fine with
docker run --env GRAVITEE_MANAGEMENT_MONGODB_URI="mongodb+srv://xx:xx@xx.xx.mongodb.net/gravitee?retryWrites=true&w=majority" graviteeio/management-api:1.25.11
Of course, a workaround is to start image (all version) with URI like:
GRAVITEE_MANAGEMENT_MONGODB_URI="mongodb://xx:xx@xx-shard-00-00-xx.xx.mongodb.net:27017,xx-shard-00-01-xx.xx.mongodb.net:27017,xx-shard-00-02-xx.xx.mongodb.net:27017/gravitee?authSource=admin&replicaSet=xx-shard-0&ssl=true&retryWrites=true&w=majority"
( URI mongo <= 3.4 )
It'll be fixed thanks to https://github.com/gravitee-io/issues/issues/3235
Hello
Since 1.25.12, when we use mongo backend, all components (gw, mgmt api) which use URI like
mongodb+srv://user:password@xxxxx.xx.mongodb.net/gravitee?retryWrites=true
fail to start.( ie: using seed list: https://www.mongodb.com/blog/post/mongodb-3-6-here-to-SRV-you-with-easier-replica-set-connections)
Expected Behavior
In 1.25.11:
Current Behavior
In 1.25.12 / 1.25.13 / 1.29.4 :
Possible Solution
I'm not sure but it seems that this issue was introduced with the commit https://github.com/gravitee-io/gravitee-repository-mongodb/commit/87ff9e1735d2ce31f46e461f5be71c85d48afa7c (between 1.25.11 and 1.25.12 )
Steps to Reproduce (for bugs)
Context
MongoDB database hosted on mongoAtlas.
Your Environment
Feel free if you have any question.