azavea / cac-tripplanner

Clean Air Council Circuit Trip Planner and Travelshed
https://gophillygo.org/
Other
15 stars 7 forks source link

Ansible provisioning fails to run migrations due to issue with psycopg2 #1032

Closed maurizi closed 6 years ago

maurizi commented 6 years ago

Failing task from vagrant up:

TASK [cac-tripplanner.app : Run migrations] ************************************
fatal: [app]: FAILED! => {"changed": false, "cmd": "./manage.py migrate --noinput", "msg": "\n:stderr: /usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use \"pip install psycopg2-binary\" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.\n  \"\"\")\nTraceback (most recent call last):\n  File \"./manage.py\", line 10, in <module>\n    execute_from_command_line(sys.argv)\n  File \"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py\", line 364, in execute_from_command_line\n    utility.execute()\n  File \"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py\", line 356, in execute\n    self.fetch_command(subcommand).run_from_argv(self.argv)\n  File \"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py\", line 283, in run_from_argv\n    self.execute(*args, **cmd_options)\n  File \"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py\", line 330, in execute\n    output = self.handle(*args, **options)\n  File \"/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py\", line 81, in handle\n    connection.prepare_database()\n  File \"/usr/local/lib/python2.7/dist-packages/django/contrib/gis/db/backends/postgis/base.py\", line 25, in prepare_database\n    with self.cursor() as cursor:\n  File \"/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py\", line 254, in cursor\n    return self._cursor()\n  File \"/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py\", line 229, in _cursor\n    self.ensure_connection()\n  File \"/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py\", line 213, in ensure_connection\n    self.connect()\n  File \"/usr/local/lib/python2.7/dist-packages/django/db/utils.py\", line 94, in __exit__\n    six.reraise(dj_exc_type, dj_exc_value, traceback)\n  File \"/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py\", line 213, in ensure_connection\n    self.connect()\n  File \"/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py\", line 189, in connect\n    self.connection = self.get_new_connection(conn_params)\n  File \"/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql/base.py\", line 176, in get_new_connection\n    connection = Database.connect(**conn_params)\n  File \"/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py\", line 130, in connect\n    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)\ndjango.db.utils.OperationalError: could not connect to server: Connection refused\n\tIs the server running on host \"kolkata.internal.azavea.com\" (172.26.100.11) and accepting\n\tTCP/IP connections on port 5432?\n\n", "path": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin", "state": "absent", "syspath": ["/tmp/ansible_2IbF1X", "/tmp/ansible_2IbF1X/ansible_modlib.zip", "/tmp/ansible_2IbF1X/ansible_modlib.zip", "/usr/lib/python2.7", "/usr/lib/python2.7/plat-x86_64-linux-gnu", "/usr/lib/python2.7/lib-tk", "/usr/lib/python2.7/lib-old", "/usr/lib/python2.7/lib-dynload", "/usr/local/lib/python2.7/dist-packages", "/usr/lib/python2.7/dist-packages"]}
flibbertigibbet commented 6 years ago

The psycopg2 message is just a warning; if you run the migrations directly, you can see the actual error masked in the ansible output.

vagrant ssh app
cd /opt/app/python/cac_tripplanner
./manage.py migrate

If the provision had failed otherwise previously, it may simply need to be re-run; missing packages for that reason may cause this.

maurizi commented 6 years ago

This was indeed unrelated to psycopg2