I know we can connect to replica set using pymongo and it can automatically figure out which one is primary under normal circumstances. However, our replica set is running inside of containers, therefore, the hostname registered in the replica set configuration are not pingable outside of containers. I can only access the instance on a per node basis by supplying the IP of the host where the container reside. My question arise from the need to figure out if the node I connect to is indeed primary, I know to check that under mongo shell, I could do either rs.isMaster() or db.isMaster().ismaster, but neither seems to work with my client connection via pymongo.
Hopefully my question is clear enough, if not please leave a comment and I can try to elaborate, any help is greatly appreciated. Thanks in advance. In the meantime, I will keep trying other things.