Skip to content

Partial Migrations on Local Docker Install #9077

Closed

Description

@rooftopcellist
ISSUE TYPE
  • Bug Report
SUMMARY

I seeing migrations only partially run on Local Docker installations. It seems as those sometimes, the migrations will run in the background and finish, but other times, only 5 migrations are run.

ENVIRONMENT
  • AWX version: X.Y.Z
  • AWX install method: openshift, minishift, docker on linux, docker for mac, boot2docker
  • Ansible version: X.Y.Z
  • Operating System:
  • Web Browser:
STEPS TO REPRODUCE
ansible-playbook -i inventory install.yml -vv
EXPECTED RESULTS

Successful install, no errors.

ACTUAL RESULTS

Only 5 migrations run (none from the main app), installer fails early on "Create Preload data" task.

ADDITIONAL INFORMATION

Traceback from installer:

TASK [local_docker : Create Preload data] **************************************************************************************
task path: /home/chadams/awx/installer/roles/local_docker/tasks/compose.yml:53
fatal: [localhost]: FAILED! => {"changed": false, "cmd": ["docker", "exec", "awx_task", "bash", "-c", "/usr/bin/awx-manage create_preload_data"], "delta": "0:00:03.845744", "end": "2021-01-13 11:05:35.771060", "msg": "non-zero return code", "rc": 1, "start": "2021-01-13 11:05:31.925316", "stderr": "Traceback (most recent call last):\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 84, in _execute\n    return self.cursor.execute(sql, params)\npsycopg2.errors.UndefinedTable: relation \"main_organization\" does not exist\nLINE 1: SELECT COUNT(*) AS \"__count\" FROM \"main_organization\"\n                                          ^\n\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/usr/bin/awx-manage\", line 8, in <module>\n    sys.exit(manage())\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/__init__.py\", line 154, in manage\n    execute_from_command_line(sys.argv)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line\n    utility.execute()\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/__init__.py\", line 375, in execute\n    self.fetch_command(subcommand).run_from_argv(self.argv)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/base.py\", line 323, in run_from_argv\n    self.execute(*args, **cmd_options)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/base.py\", line 364, in execute\n    output = self.handle(*args, **options)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/management/commands/create_preload_data.py\", line 17, in handle\n    if Organization.objects.count():\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/manager.py\", line 82, in manager_method\n    return getattr(self.get_queryset(), name)(*args, **kwargs)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py\", line 392, in count\n    return self.query.get_count(using=self.db)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/query.py\", line 504, in get_count\n    number = obj.get_aggregation(using, ['__count'])['__count']\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/query.py\", line 489, in get_aggregation\n    result = compiler.execute_sql(SINGLE)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/compiler.py\", line 1142, in execute_sql\n    cursor.execute(sql, params)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 67, in execute\n    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 76, in _execute_with_wrappers\n    return executor(sql, params, many, context)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 84, in _execute\n    return self.cursor.execute(sql, params)\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/utils.py\", line 89, in __exit__\n    raise dj_exc_value.with_traceback(traceback) from exc_value\n  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 84, in _execute\n    return self.cursor.execute(sql, params)\ndjango.db.utils.ProgrammingError: relation \"main_organization\" does not exist\nLINE 1: SELECT COUNT(*) AS \"__count\" FROM \"main_organization\"\n                                          ^", "stderr_lines": ["Traceback (most recent call last):", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 84, in _execute", "    return self.cursor.execute(sql, params)", "psycopg2.errors.UndefinedTable: relation \"main_organization\" does not exist", "LINE 1: SELECT COUNT(*) AS \"__count\" FROM \"main_organization\"", "                                          ^", "", "", "The above exception was the direct cause of the following exception:", "", "Traceback (most recent call last):", "  File \"/usr/bin/awx-manage\", line 8, in <module>", "    sys.exit(manage())", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/__init__.py\", line 154, in manage", "    execute_from_command_line(sys.argv)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/__init__.py\", line 381, in execute_from_command_line", "    utility.execute()", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/__init__.py\", line 375, in execute", "    self.fetch_command(subcommand).run_from_argv(self.argv)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/base.py\", line 323, in run_from_argv", "    self.execute(*args, **cmd_options)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/base.py\", line 364, in execute", "    output = self.handle(*args, **options)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/management/commands/create_preload_data.py\", line 17, in handle", "    if Organization.objects.count():", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/manager.py\", line 82, in manager_method", "    return getattr(self.get_queryset(), name)(*args, **kwargs)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/query.py\", line 392, in count", "    return self.query.get_count(using=self.db)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/query.py\", line 504, in get_count", "    number = obj.get_aggregation(using, ['__count'])['__count']", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/query.py\", line 489, in get_aggregation", "    result = compiler.execute_sql(SINGLE)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/models/sql/compiler.py\", line 1142, in execute_sql", "    cursor.execute(sql, params)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 67, in execute", "    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 76, in _execute_with_wrappers", "    return executor(sql, params, many, context)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 84, in _execute", "    return self.cursor.execute(sql, params)", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/utils.py\", line 89, in __exit__", "    raise dj_exc_value.with_traceback(traceback) from exc_value", "  File \"/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py\", line 84, in _execute", "    return self.cursor.execute(sql, params)", "django.db.utils.ProgrammingError: relation \"main_organization\" does not exist", "LINE 1: SELECT COUNT(*) AS \"__count\" FROM \"main_organization\"", "                                          ^"], "stdout": "", "stdout_lines": []}

Activity

  1. rooftopcellist commented on Jan 13, 2021

    @rooftopcellist
    MemberAuthor

    I have also noticed this separate issue where the create preload data step fails because the admin user is not available. I believe this is because services haven't fully come up yet because the admin user can be in the database already and the error will still occur.

    image

    Adding a 10 second wait (5 wasn't enough)

  2. rooftopcellist commented on Jan 14, 2021

    @rooftopcellist
    MemberAuthor

    FYI, this is what happens for me on fresh installs of 16.0.0.

    Operations to perform:
      Apply all migrations: auth, conf, contenttypes, main, oauth2_provider, sessions, sites, social_django, sso, taggit
    Running migrations:
      Applying contenttypes.0001_initial... OK
      Applying contenttypes.0002_remove_content_type_name... OK
      Applying taggit.0001_initial... OK
      Applying taggit.0002_auto_20150616_2121... OK
      Applying auth.0001_initial... OK
    Traceback (most recent call last):
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py", line 82, in _execute
        return self.cursor.execute(sql)
    psycopg2.OperationalError: server closed the connection unexpectedly
    	This probably means the server terminated abnormally
    	before or while processing the request.
    
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/migrations/executor.py", line 245, in apply_migration
        state = migration.apply(state, schema_editor)
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/migrations/migration.py", line 124, in apply
        operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/migrations/operations/models.py", line 92, in database_forwards
        schema_editor.create_model(model)
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 307, in create_model
        self.execute(sql, params or None)
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 137, in execute
        cursor.execute(sql, params)
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py", line 67, in execute
        return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
        return executor(sql, params, many, context)
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
        return self.cursor.execute(sql, params)
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
        raise dj_exc_value.with_traceback(traceback) from exc_value
      File "/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/db/backends/utils.py", line 82, in _execute
        return self.cursor.execute(sql)
    django.db.utils.OperationalError: server closed the connection unexpectedly
    	This probably means the server terminated abnormally
    	before or while processing the request.
    

    Migrations never finish (waited 30 min).

    15.0.1 works without issue.

  3. rooftopcellist commented on Jan 19, 2021

    @rooftopcellist
    MemberAuthor

    This is fixed in #9113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions