[CDRIVER-4682] Log informational message client-side based on detected environment (DocumentDB or CosmosDB) Created: 14/Jul/23  Updated: 28/Oct/23  Resolved: 14/Sep/23

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.25.0

Type: Task Priority: Major - P3
Reporter: PM Bot Assignee: Jeremy Mikola
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CXX-2713 Log informational message client-side... Closed
Issue split
Related
is related to PHPLIB-1194 Log informational message client-side... Closed
Quarter: FY24Q3
Upstream Changes Summary:

DRIVERS-2583:
Drivers should detect Cosmos and DocumentDB servers by examining host names added to a topology during MongoClient construction. If SRV is used, this check should be done on the SRV URI's `{hostname}.{domainname}` prior to SRV lookup (ex: xyz.mongodb.net).

If one or more host names end with ".cosmos.azure.com" (case-insensitive), log the following message using an "info" level:

You appear to be connected to a CosmosDB cluster. For more information regarding feature compatibility and support please visit https://www.mongodb.com/supportability/cosmosdb

If one or more host names end with ".docdb.amazonaws.com" or ".docdb-elastic.amazonaws.com" (case-insensitive), log the following message using an "info" level:

You appear to be connected to a DocumentDB cluster. For more information regarding feature compatibility and support please visit https://www.mongodb.com/supportability/documentdb

Drivers should not emit more than one log message per MongoClient construction.

Note: there are no spec/prose tests for this ticket. Each driver should implement its own set of tests for this behavior. The libmongoc tests from mongodb/mongo-c-driver#1374 may be used as a reference.
Note#2: Refer to DRIVERS-2753 if using standardized logging.

Backwards Compatibility: Fully Compatible

 Description   

This ticket was split from DRIVERS-2583, please see that ticket for a detailed description.



 Comments   
Comment by Githook User [ 14/Sep/23 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-4682 Detect non-MongoDB host names before SRV lookup. (#1401)

  • print failing URI on test failure
  • refactor `_detect_nongenuine_hosts` to use separate helper and accept `mongoc_uri_t`
  • move `_detect_nongenuine_hosts` earlier

This is intended to ease testing. Tests using bogus URIs will fail SRV lookup. Checking before SRV lookup allows tests to observe the log.

  • check SRV hostname

---------

Co-authored-by: Jeremy Mikola <jmikola@gmail.com>
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/fe68d3b0c878c7bb1ba7083d713daa392835e441

Comment by Alex Bevilacqua [ 07/Sep/23 ]

jmikola@mongodb.com / rishabh.bisht@mongodb.com as discussed on DRIVERS-2583 I'm reopening this ticket to adjust the implementation per the update change summary:

Drivers should detect Cosmos and DocumentDB servers by examining host names added to a topology during MongoClient construction. If SRV is used, this check should be done on the SRV URI's `{hostname}.{domainname}` prior to SRV lookup (ex: xyz.mongodb.net).

Comment by Githook User [ 21/Aug/23 ]

Author:

{'name': 'Jeremy Mikola', 'email': 'jmikola@gmail.com', 'username': 'jmikola'}

Message: CDRIVER-4682 log informational message for nongenuine hosts (#1374)

Nongenuine hosts are detected after SRV resolution; however, we cannot easily mock SRV responses so that is intentionally not tested.

Matching is anchored to the end of the host string. This necessitated moving mongoc-uri's ends_with function to mongoc-util in order to share it with mongoc-topology.

Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/36c1f141b55272f8d09a8492ef74fd9d701d16f6

Comment by Jeremy Mikola [ 08/Aug/23 ]

https://github.com/mongodb/mongo-c-driver/pull/1374

Generated at Wed Feb 07 21:21:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.