Problem upgrading openwisp2 (multitenancy)

200 views
Skip to first unread message

Alvaro Mendez

unread,
May 3, 2017, 12:51:57 PM5/3/17
to OpenWISP
Dear folks,

when trying to upgrade i got this error:


TASK [openwisp.openwisp2 : migrate] ********************************************
task path: /etc/ansible/roles/openwisp.openwisp2/tasks/django.yml:74
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/web_infrastructure/django_manage.py
<132.148.88.35> ESTABLISH SSH CONNECTION FOR USER: tabako
<132.148.88.35> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o User=tabako -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 132.148.88.35 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/ansible-tmp-1493829936.07-247563188619561 `" && echo ansible-tmp-1493829936.07-247563188619561="` echo /tmp/ansible-tmp-1493829936.07-247563188619561 `" ) && sleep 0'"'"''
<132.148.88.35> PUT /tmp/tmpSFeZpN TO /tmp/ansible-tmp-1493829936.07-247563188619561/django_manage.py
<132.148.88.35> SSH: EXEC sshpass -d12 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o User=tabako -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[132.148.88.35]'
<132.148.88.35> ESTABLISH SSH CONNECTION FOR USER: tabako
<132.148.88.35> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o User=tabako -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 132.148.88.35 '/bin/sh -c '"'"'setfacl -m u:www-data:r-x /tmp/ansible-tmp-1493829936.07-247563188619561/ /tmp/ansible-tmp-1493829936.07-247563188619561/django_manage.py && sleep 0'"'"''
<132.148.88.35> ESTABLISH SSH CONNECTION FOR USER: tabako
<132.148.88.35> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o User=tabako -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r -tt 132.148.88.35 '/bin/sh -c '"'"'sudo -H -S  -p "[sudo via ansible, key=eoclcccijryxechynwgnbcpbjpxzdrcn] password: " -u www-data /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-eoclcccijryxechynwgnbcpbjpxzdrcn; /usr/bin/python /tmp/ansible-tmp-1493829936.07-247563188619561/django_manage.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
<132.148.88.35> ESTABLISH SSH CONNECTION FOR USER: tabako
<132.148.88.35> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o User=tabako -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 132.148.88.35 '/bin/sh -c '"'"'rm -f -r /tmp/ansible-tmp-1493829936.07-247563188619561/ > /dev/null 2>&1 && sleep 0'"'"''
fatal: [132.148.88.35]: FAILED! => {
    "changed": false,
    "cmd": "./manage.py migrate --noinput",
    "failed": true,
    "invocation": {
        "module_args": {
            "app_path": "/opt/openwisp2",
            "apps": null,
            "cache_table": null,
            "clear": null,
            "command": "migrate",
            "database": null,
            "failfast": false,
            "fixtures": null,
            "link": null,
            "liveserver": null,
            "merge": null,
            "pythonpath": null,
            "settings": null,
            "skip": null,
            "testrunner": null,
            "virtualenv": "/opt/openwisp2/env"
        },
        "module_name": "django_manage"
    },
    "msg": "stdout: Operations to perform:\n  Apply all migrations: account, admin, auth, config, contenttypes, openwisp_users, pki, reversion, sessions, sites, socialaccount\nRunning migrations:\n  Applying config.0002_config_settings_uuid...\n:stderr: Traceback (most recent call last):\n  File \"./manage.py\", line 10, in <module>\n    execute_from_command_line(sys.argv)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/__init__.py\", line 367, in execute_from_command_line\n    utility.execute()\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/__init__.py\", line 359, in execute\n    self.fetch_command(subcommand).run_from_argv(self.argv)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/base.py\", line 294, in run_from_argv\n    self.execute(*args, **cmd_options)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/base.py\", line 345, in execute\n    output = self.handle(*args, **options)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py\", line 204, in handle\n    fake_initial=fake_initial,\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/executor.py\", line 115, in migrate\n    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/executor.py\", line 145, in _migrate_all_forwards\n    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/executor.py\", line 244, in apply_migration\n    state = migration.apply(state, schema_editor)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/migration.py\", line 129, in apply\n    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py\", line 204, in database_forwards\n    schema_editor.alter_field(from_model, from_field, to_field)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/backends/base/schema.py\", line 495, in alter_field\n    old_db_params, new_db_params, strict)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/backends/postgresql/schema.py\", line 117, in _alter_field\n    new_db_params, strict,\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/backends/base/schema.py\", line 649, in _alter_field\n    params,\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/backends/base/schema.py\", line 112, in execute\n    cursor.execute(sql, params)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/backends/utils.py\", line 64, in execute\n    return self.cursor.execute(sql, params)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/utils.py\", line 94, in __exit__\n    six.reraise(dj_exc_type, dj_exc_value, traceback)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/backends/utils.py\", line 64, in execute\n    return self.cursor.execute(sql, params)\ndjango.db.utils.ProgrammingError: cannot cast type integer to uuid\nLINE 1: ...igsettings\" ALTER COLUMN \"id\" TYPE uuid USING \"id\"::uuid, AL...\n                                                             ^\n\n",
    "path": "/opt/openwisp2/env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin",
    "state": "absent",
    "syspath": [
        "/tmp/ansible_RFedDl",
        "/tmp/ansible_RFedDl/ansible_modlib.zip",
        "/tmp/ansible_RFedDl/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"
    ]
}


Thanks for your time!

Federico Capoano

unread,
May 3, 2017, 1:10:35 PM5/3/17
to OpenWISP
Hi Alvaro,

I'm sorry to see you incurred in this case.

I see you are using postgres, is that correct? I did test the migration on sqlite and mysql but not on postgres, I naively supposed it would work but that didn't seem the case.

Is yours a production system or a test installation?

Federico

--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alvaro Mendez

unread,
May 3, 2017, 1:38:31 PM5/3/17
to OpenWISP
Hi Federico is a test instalation waiting for production hahaha.

Very complicated for fix? 

Best Regards. 

To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "OpenWISP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openwisp/B2rdQJ8TSM4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openwisp+unsubscribe@googlegroups.com.

Federico Capoano

unread,
May 3, 2017, 1:42:21 PM5/3/17
to open...@googlegroups.com
On Wed, May 3, 2017 at 7:38 PM Alvaro Mendez <ame...@opensolutions.cl> wrote:
Hi Federico is a test instalation waiting for production hahaha.
 
Did you insert a lot of routers in?

Very complicated for fix? 

I would need to spend some hours on it but I'm very busy on other issues.

Federico

Alvaro Mendez

unread,
May 3, 2017, 1:47:40 PM5/3/17
to OpenWISP
there is no problem with the installation (about routers you ask)

i thing maybe migrate to mysql instead.

but searching the web i found:

change_column :table_name, :column_name, 'integer USING CAST(column_name AS integer)'

http://stackoverflow.com/questions/13170570/change-type-of-varchar-field-to-integer-cannot-be-cast-automatically-to-type-i

maybe do the trick.

best regards.

--
You received this message because you are subscribed to a topic in the Google Groups "OpenWISP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openwisp/B2rdQJ8TSM4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openwisp+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
        Alvaro Mendez
ame...@opensolutions.cl
          8-9047532

Federico Capoano

unread,
May 3, 2017, 1:48:19 PM5/3/17
to open...@googlegroups.com
I think this is not a problem related strictly to the multi-tenancy migration.

It seems this migration is failing:

Did you back up before upgrading as I suggested when released that feature?

Federico

Federico Capoano

unread,
May 3, 2017, 1:53:39 PM5/3/17
to open...@googlegroups.com
I've been able to reproduce the issue.

I will update you shortly.

Alvaro Mendez

unread,
May 3, 2017, 1:54:19 PM5/3/17
to OpenWISP
thank you very much!!!

--
You received this message because you are subscribed to a topic in the Google Groups "OpenWISP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openwisp/B2rdQJ8TSM4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openwisp+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Federico Capoano

unread,
May 3, 2017, 2:07:18 PM5/3/17
to open...@googlegroups.com
I've just pushed a fix:
https://github.com/openwisp/openwisp-controller/commit/d173c248e21dceadf69cb314ac7ca2887a350f9d

Try the following procedure:
  1. restore a backup/snapshot
  2. set the variable openwisp2_controller_dev and openwisp2_django_netjsonconfig_dev to true in your ansible playbook, see Role variables for an example
  3. repeat the upgrade
In the very unfortunate case in which you don't have a backup, perform only step 2 and 3 and cross your fingers...

Federico

On Wed, May 3, 2017 at 7:54 PM Alvaro Mendez <ame...@opensolutions.cl> wrote:
thank you very much!!!

2017-05-03 14:53 GMT-03:00 Federico Capoano <federico...@gmail.com>:
I've been able to reproduce the issue.

I will update you shortly.

On Wed, May 3, 2017 at 7:48 PM Federico Capoano <federico...@gmail.com> wrote:
I think this is not a problem related strictly to the multi-tenancy migration.

It seems this migration is failing:

Did you back up before upgrading as I suggested when released that feature?

Federico

On Wed, May 3, 2017 at 7:42 PM Federico Capoano <federico...@gmail.com> wrote:
On Wed, May 3, 2017 at 7:38 PM Alvaro Mendez <ame...@opensolutions.cl> wrote:
Hi Federico is a test instalation waiting for production hahaha.
 
Did you insert a lot of routers in?

Very complicated for fix? 

I would need to spend some hours on it but I'm very busy on other issues.

Federico

--
You received this message because you are subscribed to a topic in the Google Groups "OpenWISP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openwisp/B2rdQJ8TSM4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openwisp+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
        Alvaro Mendez
ame...@opensolutions.cl
          8-9047532

--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+u...@googlegroups.com.

Alvaro Mendez

unread,
May 3, 2017, 2:31:37 PM5/3/17
to OpenWISP
Well Fwderico, my bad... i dont have any backup......

    "msg": "\n:stderr: Traceback (most recent call last):\n  File \"./manage.py\", line 10, in <module>\n    execute_from_command_line(sys.argv)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/__init__.py\", line 367, in execute_from_command_line\n    utility.execute()\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/__init__.py\", line 359, in execute\n    self.fetch_command(subcommand).run_from_argv(self.argv)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/base.py\", line 294, in run_from_argv\n    self.execute(*args, **cmd_options)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/base.py\", line 345, in execute\n    output = self.handle(*args, **options)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py\", line 83, in handle\n    executor = MigrationExecutor(connection, self.migration_progress_callback)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/executor.py\", line 20, in __init__\n    self.loader = MigrationLoader(self.connection)\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/loader.py\", line 52, in __init__\n    self.build_graph()\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/loader.py\", line 267, in build_graph\n    six.reraise(NodeNotFoundError, exc_value, sys.exc_info()[2])\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/loader.py\", line 238, in build_graph\n    self.graph.validate_consistency()\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/graph.py\", line 261, in validate_consistency\n    [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]\n  File \"/opt/openwisp2/env/local/lib/python2.7/site-packages/django/db/migrations/graph.py\", line 104, in raise_error\n    raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)\ndjango.db.migrations.exceptions.NodeNotFoundError: Migration config.0003_template_tags depends on nonexistent node ('config', '0002_config_settings_uuid'). Django tried to replace migration config.0002_config_settings_uuid with any of [config.0001_squashed_0002_config_settings_uuid] but wasn't able to because some of the replaced migrations are already applied.\n",

    "path": "/opt/openwisp2/env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin",
    "state": "absent",
    "syspath": [
        "/tmp/ansible_aR9Fnq",
        "/tmp/ansible_aR9Fnq/ansible_modlib.zip",
        "/tmp/ansible_aR9Fnq/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"



is there any way to put the database from default? and them apply this upgrade?

Best Regards and thanks for your time....

To unsubscribe from this group and all its topics, send an email to openwisp+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
        Alvaro Mendez
ame...@opensolutions.cl
          8-9047532

--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "OpenWISP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openwisp/B2rdQJ8TSM4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openwisp+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Alvaro Mendez

unread,
May 3, 2017, 2:57:42 PM5/3/17
to OpenWISP
Federico, dont waste you time in this.

I already decided to re-install and use mysql as databse engine. i tell you how it goes....

Thanks.
Reply all
Reply to author
Forward
0 new messages