fiware-orion icon indicating copy to clipboard operation
fiware-orion copied to clipboard

mongodriver follow up: -mongoUri CLI parameter

Open fgalan opened this issue 4 years ago • 5 comments

Modern mongo drivers use mongo URI (i.e. mongo://...) as a connection string to connect to MongoDB servers. It would be very beneficial (and pretty easy) to implement this in Orion, in a new parameter -mongoUri (checking that is not used at the same time than other parameters currently used to compose the URL, e.g. -dbhost are not used at the same time).

This would allow overcoming limitations in the current connection mode (we don't support every possible connection parameter in CLI parameters and adding more parameters would not be a scalable solution).

The preferred conection mode would be -mongoUri and the following CLI flags would be deprecated (a WARN message will be printed if some of them is used):

  • dbhost
  • rplSet
  • dbuser
  • dbpwd
  • dbAuthMech
  • dbAuthDb
  • dbSSL
  • dbTimeout

fgalan avatar Mar 01 '21 13:03 fgalan

Solving this issue also will solve the limitation currently described in cli.md with regards to -dbSSL switch:

Note there is currently a limitation: Orion uses tlsAllowInvalidCertificates=true in this case, so the certificate used by MongoDB server is not being validated.

fgalan avatar Mar 05 '21 13:03 fgalan

This SOF question would need modification upon completion of this issue: https://stackoverflow.com/questions/69932011/orion-contextbroker-allows-set-read-preference-to-mongodb-replicaset/69944749#69944749

fgalan avatar Nov 12 '21 14:11 fgalan

This another SOF question would need modification upon completion of this issue: https://stackoverflow.com/questions/70186342/fiware-orion-with-atlas-mongodb

fgalan avatar Jan 20 '22 12:01 fgalan

Hey there, I just wanted to check if you guys plan on working on this soon :) I'm also interested in setting the read preference.

SBlechmann avatar Mar 01 '22 11:03 SBlechmann

Hey there, I just wanted to check if you guys plan on working on this soon :) I'm also interested in setting the read preference.

Not at the present moment, but maybe you (or any other in the community with this need) want to work on it. It is not a difficult implementation and we could provide some feedback on it, along with pull request review, of course.

Thanks in advance to any brave volunteer! :)

fgalan avatar Mar 01 '22 13:03 fgalan

Hello, I would like to know if anyone was successful in fixing this problem otherwise I might try to do it for my project. Thank you in advance

eduardoCarneiro99 avatar Nov 26 '22 18:11 eduardoCarneiro99

As far as I know, nobody is working on this, so feel free on taking the issue :)

Thanks for your willingness to contribute!

fgalan avatar Nov 28 '22 16:11 fgalan

I already implemented this for Orion-LD, some time ago. I called the CLI param "-dbURI' as it is no longer only mongo in the game (DocumentDB, CosmosDB, ...) You can borrow from there if you want to: https://github.com/FIWARE/context.Orion-LD/blob/develop/src/lib/orionld/mongoc/mongocInit.cpp#L130

Especially, I got the request to have the password separate, not in the same CLI as the rest, so I implemented a replace functionality for the resulting URI - that's something you might want to keep in mind, using my implementation or not.

kzangeli avatar Nov 28 '22 16:11 kzangeli

Thank you very much, I will try to do this this week and I will make sure to mention you in the PR._

eduardoCarneiro99 avatar Dec 05 '22 15:12 eduardoCarneiro99

PR #4385

fgalan avatar Aug 09 '23 11:08 fgalan