Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

TypeError("port must be an instance of int") while configuring MongoDB #2406

Closed
JaapJoris opened this issue Oct 26, 2015 · 3 comments
Closed

Comments

@JaapJoris
Copy link

Running the ansible playbook edx_sandbox.yml results in an error syncing the MongoDB database. The error is "port must be an instance of int" (see the traceback below). I suspect the mongo_port variable is being supplied as a string instead of an int.

Error in migration: student:0035_access_roles
failed: [edx] => (item=cms) => {"changed": true, "cmd": ["/edx/bin/edxapp-syncdb-cms"], "delta": "0:00:03.468389", "end": "2015-10-26 14:12:00.826554", "item": "cms", "rc": 1, "start": "2015-10-26 14:11:57.358165", "warnings": []}
stderr: 2015-10-26 09:11:59,107 INFO 30348 [dd.dogapi] dog_stats_api.py:66 - Initializing dog api to use statsd: localhost, 8125
Traceback (most recent call last):
  File "manage.py", line 116, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 103, in handle_noargs
    management.call_command('migrate', **options)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command
    return klass.execute(*args, **defaults)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
    ignore_ghosts = ignore_ghosts,
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/south/migration/__init__.py", line 220, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/south/migration/migrators.py", line 256, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/south/migration/migrators.py", line 331, in migrate_many
    result = self.migrate(migration, database)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/south/migration/migrators.py", line 133, in migrate
    result = self.run(migration, database)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/south/migration/migrators.py", line 114, in run
    return self.run_migration(migration, database)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/south/migration/migrators.py", line 84, in run_migration
    migration_function()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/south/migration/migrators.py", line 60, in <lambda>
    return (lambda: direction(orm))
  File "/edx/app/edxapp/edx-platform/common/djangoapps/student/migrations/0035_access_roles.py", line 34, in forwards
    store = modulestore()
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/django.py", line 206, in modulestore
    contentstore(),
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/contentstore/django.py", line 28, in contentstore
    _CONTENTSTORE[name] = class_(**options)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/contentstore/mongo.py", line 39, in __init__
    **kwargs
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 248, in __init__
    raise TypeError("port must be an instance of int")
TypeError: port must be an instance of int
@JaapJoris
Copy link
Author

I have found the culprit, it's in lines 639 and 676 of playbooks/roles/edxapp/defaults/main.yml:

port: "{{ EDXAPP_MONGO_PORT }}"

This syntax coerces the EDXAPP_MONGO_PORT variable to a string, which ends up in the file /edx/app/edxapp/cms.auth.json on the production system as follows:

"DOC_STORE_CONFIG": {
    "collection": "modulestore", 
    "db": "edxapp", 
    "host": [
        "localhost"
    ], 
    "password": "password", 
    "port": "27017", 
    "ssl": "False", 
    "user": "edxapp"
}, 

The pymongo client then refuses to connect since the port number is not a string. A simple solution would be to simply replace the two instances of EDXAPP_MONGO_PORT with the value 27017 (without quotes), but this leads to duplication. A better solution is currently prohibited because of Ansible issues 5463 and 12071.

Edit - A possible fix will be released with Ansible 2.0.

@e0d
Copy link
Contributor

e0d commented Oct 26, 2015

Are you using the edX fork of Ansible specified in our requirements.txt file? We fixed this issue and pushed the fix upstream.

Our config looks like so

        "port": 27017,

and is happy.

@JaapJoris
Copy link
Author

No, I was using Ansible 1.9.4 from another computer. Apparently I ran into a problem that you guys already fixed in your own Ansible fork! I'll close this issue then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants