Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Failed to validate mongod version #2961

Closed
4 tasks
ufosoftwarellc opened this issue May 5, 2023 · 8 comments
Closed
4 tasks

[BUG] Failed to validate mongod version #2961

ufosoftwarellc opened this issue May 5, 2023 · 8 comments
Labels
bug Bug fixes

Comments

@ufosoftwarellc
Copy link

ufosoftwarellc commented May 5, 2023

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 22.04.2 LTS (GNU/Linux 5.19.0-41-generic x86_64)
  • Python version (python --version): 3.10.9
  • FiftyOne version (fiftyone --version): 0.20.1
  • FiftyOne installed from (pip or source): pip
  • MongoDB version: 6.0.5

Commands to reproduce

As thoroughly as possible, please provide the Python and/or shell commands used to encounter the issue. Application steps can be described in the next section.

import fiftyone as fo

Describe the problem

importing FiftyOne using a shared MongoDB returns: Failed to validate mongod version
"database_validation": false set in config.json

Code to reproduce issue

import fiftyone as fo

Other info/logs

config.json

{
"database_validation": false,
"database_uri": "mongodb://xxx:xxx@localhost:xxxx/?authSource=ad>
}


OperationFailure Traceback (most recent call last)
File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/fiftyone/core/odm/database.py:286, in _validate_db_version(config, client)
285 try:
--> 286 version = Version(client.server_info()["version"])
287 except Exception as e:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/mongo_client.py:1805, in MongoClient.server_info(self, session)
1794 """Get information about the MongoDB server we're connected to.
1795
1796 :Parameters:
(...)
1801 Added session parameter.
1802 """
1803 return cast(
1804 dict,
-> 1805 self.admin.command(
1806 "buildinfo", read_preference=ReadPreference.PRIMARY, session=session
1807 ),
1808 )

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/_csot.py:105, in apply..csot_wrapper(self, *args, **kwargs)
104 return func(self, *args, **kwargs)
--> 105 return func(self, *args, **kwargs)

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/database.py:805, in Database.command(self, command, value, check, allowable_errors, read_preference, codec_options, session, comment, **kwargs)
804 read_preference = (session and session._txn_read_preference()) or ReadPreference.PRIMARY
--> 805 with self.__client._socket_for_reads(read_preference, session) as (
806 sock_info,
807 read_preference,
808 ):
809 return self._command(
810 sock_info,
811 command,
(...)
818 **kwargs,
819 )

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/contextlib.py:135, in _GeneratorContextManager.enter(self)
134 try:
--> 135 return next(self.gen)
136 except StopIteration:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/mongo_client.py:1282, in MongoClient._socket_from_server(self, read_preference, server, session)
1280 single = topology.description.topology_type == TOPOLOGY_TYPE.Single
-> 1282 with self._get_socket(server, session) as sock_info:
1283 if single:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/contextlib.py:135, in _GeneratorContextManager.enter(self)
134 try:
--> 135 return next(self.gen)
136 except StopIteration:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/mongo_client.py:1217, in MongoClient._get_socket(self, server, session)
1216 return
-> 1217 with server.get_socket(handler=err_handler) as sock_info:
1218 # Pin this session to the selected server or connection.
1219 if in_txn and server.description.server_type in (
1220 SERVER_TYPE.Mongos,
1221 SERVER_TYPE.LoadBalancer,
1222 ):

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/contextlib.py:135, in _GeneratorContextManager.enter(self)
134 try:
--> 135 return next(self.gen)
136 except StopIteration:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/pool.py:1407, in Pool.get_socket(self, handler)
1405 listeners.publish_connection_check_out_started(self.address)
-> 1407 sock_info = self._get_socket(handler=handler)
1409 if self.enabled_for_cmap:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/pool.py:1520, in Pool._get_socket(self, handler)
1519 try:
-> 1520 sock_info = self.connect(handler=handler)
1521 finally:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/pool.py:1378, in Pool.connect(self, handler)
1376 handler.contribute_socket(sock_info, completed_handshake=False)
-> 1378 sock_info.authenticate()
1379 except BaseException:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/pool.py:870, in SocketInfo.authenticate(self)
869 if creds:
--> 870 auth.authenticate(creds, self)
871 self.ready = True

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/auth.py:549, in authenticate(credentials, sock_info)
548 auth_func = _AUTH_MAP[mechanism]
--> 549 auth_func(credentials, sock_info)

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/auth.py:473, in _authenticate_default(credentials, sock_info)
472 if "SCRAM-SHA-256" in mechs:
--> 473 return _authenticate_scram(credentials, sock_info, "SCRAM-SHA-256")
474 else:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/auth.py:241, in _authenticate_scram(credentials, sock_info, mechanism)
234 cmd = SON(
235 [
236 ("saslContinue", 1),
(...)
239 ]
240 )
--> 241 res = sock_info.command(source, cmd)
243 parsed = _parse_scram_response(res["payload"])

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/pool.py:767, in SocketInfo.command(self, dbname, spec, read_preference, codec_options, check, allowable_errors, read_concern, write_concern, parse_write_concern_error, collation, session, client, retryable_write, publish_events, user_fields, exhaust_allowed)
766 try:
--> 767 return command(
768 self,
769 dbname,
770 spec,
771 self.is_mongos,
772 read_preference,
773 codec_options,
774 session,
775 client,
776 check,
777 allowable_errors,
778 self.address,
779 listeners,
780 self.max_bson_size,
781 read_concern,
782 parse_write_concern_error=parse_write_concern_error,
783 collation=collation,
784 compression_ctx=self.compression_context,
785 use_op_msg=self.op_msg_enabled,
786 unacknowledged=unacknowledged,
787 user_fields=user_fields,
788 exhaust_allowed=exhaust_allowed,
789 write_concern=write_concern,
790 )
791 except (OperationFailure, NotPrimaryError):

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/network.py:166, in command(sock_info, dbname, spec, is_mongos, read_preference, codec_options, session, client, check, allowable_errors, address, listeners, max_bson_size, read_concern, parse_write_concern_error, collation, compression_ctx, use_op_msg, unacknowledged, user_fields, exhaust_allowed, write_concern)
165 if check:
--> 166 helpers._check_command_response(
167 response_doc,
168 sock_info.max_wire_version,
169 allowable_errors,
170 parse_write_concern_error=parse_write_concern_error,
171 )
172 except Exception as exc:

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/pymongo/helpers.py:181, in _check_command_response(response, max_wire_version, allowable_errors, parse_write_concern_error)
179 raise CursorNotFound(errmsg, code, response, max_wire_version)
--> 181 raise OperationFailure(errmsg, code, response, max_wire_version)

OperationFailure: Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'}

The above exception was the direct cause of the following exception:

RuntimeError Traceback (most recent call last)
Cell In[1], line 4
1 #from skimage import io
2 #import os
----> 4 import fiftyone as fo
5 #import fiftyone.utils.data as foud

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/fiftyone/init.py:25
21 import fiftyone.constants as _foc
23 version = _foc.VERSION
---> 25 from fiftyone.public import *
27 import fiftyone.core.uid as _fou
28 import fiftyone.core.logging as _fol

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/fiftyone/public.py:15
12 annotation_config = _foc.load_annotation_config()
13 app_config = _foc.load_app_config()
---> 15 _foo.establish_db_conn(config)
17 from .core.aggregations import (
18 Aggregation,
19 Bounds,
(...)
31 Values,
32 )
33 from .core.collections import SaveContext

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/fiftyone/core/odm/database.py:214, in establish_db_conn(config)
209 raise error
211 _client = pymongo.MongoClient(
212 **_connection_kwargs, appname=foc.DATABASE_APPNAME
213 )
--> 214 _validate_db_version(config, _client)
216 # Register cleanup method
217 atexit.register(_delete_non_persistent_datasets_if_allowed)

File ~/mambaforge/envs/linux_pytorch_env/lib/python3.10/site-packages/fiftyone/core/odm/database.py:291, in _validate_db_version(config, client)
288 if isinstance(e, ServerSelectionTimeoutError):
289 raise ConnectionError("Could not connect to mongod") from e
--> 291 raise RuntimeError("Failed to validate mongod version") from e
293 if config.database_validation and version < foc.MIN_MONGODB_VERSION:
294 raise RuntimeError(
295 "Found mongod version %s, but only %s and higher are "
296 "compatible. You can suppress this exception by setting your "
(...)
299 "for more information" % (version, foc.MIN_MONGODB_VERSION)
300 )

RuntimeError: Failed to validate mongod version

What areas of FiftyOne does this bug affect?

  • [ x] App: FiftyOne application issue
  • Core: Core Python library issue
  • Server: FiftyOne server issue

Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the FiftyOne codebase?

  • Yes. I can contribute a fix for this bug independently
  • Yes. I would be willing to contribute a fix for this bug with guidance from the FiftyOne community
  • [x ] No. I cannot contribute a bug fix at this time
@ufosoftwarellc ufosoftwarellc added the bug Bug fixes label May 5, 2023
@brimoor
Copy link
Contributor

brimoor commented May 5, 2023

Can you please share the full stack trace? There's some kind of issue connecting to the mongod server that you've configured via database_uri.

Specifically it is this line that is failing:

version = Version(client.server_info()["version"])

which is just making a harmless call to grab some info from mongod. You'll notice in the code that this value is not actually used for anything in your case, since you have database_validation=False.

@ufosoftwarellc
Copy link
Author

@brimoor I added the stack trace

@brimoor
Copy link
Contributor

brimoor commented May 5, 2023

Okay the original error is:

OperationFailure: Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'}

which suggests that your mongo URI

mongodb://xxx:xxx@localhost:xxxx/?authSource=ad>

isn't correct for your setup. The format of that should be something like:

mongodb://[username:password@]host[:port][/?authSource=admin][&tls=true]

@ufosoftwarellc
Copy link
Author

Thank you for your help Brian, I missed the authentication error.
The URI that worked for me is:
"database_uri": "mongodb://username:password@localhost:port/?authMechanism=>

@glenn-jocher
Copy link
Contributor

@brimoor @ufosoftwarellc I'm getting the same error in Google Colab. To reproduce:

!pip install fiftyone
import fiftyone
Screenshot 2023-08-05 at 13 53 30

How can I resolve this?

@brimoor
Copy link
Contributor

brimoor commented Aug 5, 2023

@glenn-jocher if you're running in Google Colab (or any other Ubuntu 22.04 machine), you must manually install the correct MongoDB version like so:

!pip install fiftyone
!pip install fiftyone-db-ubuntu2204

See also: #3321, #3236, #2900, #2737, #2480, #1988, #1803

@glenn-jocher
Copy link
Contributor

@brimoor thank, you got it!

@swheaton
Copy link
Contributor

swheaton commented Oct 7, 2023

closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fixes
Projects
None yet
Development

No branches or pull requests

4 participants