ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.46k stars 3.33k forks source link

awx-migration-24.3.0 failing #15137

Open adpavlov opened 1 week ago

adpavlov commented 1 week ago

Please confirm the following

Bug Summary

awx-migration-24.3.0 failing with following error:

Operations to perform:
  Apply all migrations: auth, conf, contenttypes, dab_rbac, dab_resource_registry, main, oauth2_provider, sessions, sites, social_django, sso
Running migrations:
2024-04-24 11:57:29,309 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Project Admin pk=RoleDefinition object (156) with 5 permissions
2024-04-24 11:57:29,313 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization Project Admin pk=RoleDefinition object (157) with 7 permissions
2024-04-24 11:57:29,317 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Project Use pk=RoleDefinition object (158) with 2 permissions
2024-04-24 11:57:29,321 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition WorkflowJobTemplate Admin pk=RoleDefinition object (159) with 5 permissions
2024-04-24 11:57:29,325 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization WorkflowJobTemplate Admin pk=RoleDefinition object (160) with 7 permissions
2024-04-24 11:57:29,329 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition WorkflowJobTemplate Execute pk=RoleDefinition object (161) with 2 permissions
2024-04-24 11:57:29,333 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition WorkflowJobTemplate Approve pk=RoleDefinition object (162) with 2 permissions
2024-04-24 11:57:29,338 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition JobTemplate Admin pk=RoleDefinition object (163) with 4 permissions
2024-04-24 11:57:29,342 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization JobTemplate Admin pk=RoleDefinition object (164) with 5 permissions
2024-04-24 11:57:29,346 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition JobTemplate Execute pk=RoleDefinition object (165) with 2 permissions
2024-04-24 11:57:29,350 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition NotificationTemplate Admin pk=RoleDefinition object (166) with 3 permissions
2024-04-24 11:57:29,354 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization NotificationTemplate Admin pk=RoleDefinition object (167) with 5 permissions
2024-04-24 11:57:29,358 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Team Admin pk=RoleDefinition object (168) with 4 permissions
2024-04-24 11:57:29,362 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization Team Admin pk=RoleDefinition object (169) with 6 permissions
2024-04-24 11:57:29,366 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Team Member pk=RoleDefinition object (170) with 2 permissions
2024-04-24 11:57:29,370 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization Admin pk=RoleDefinition object (171) with 5 permissions
2024-04-24 11:57:29,374 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization Organization Admin pk=RoleDefinition object (172) with 5 permissions
2024-04-24 11:57:29,378 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization Member pk=RoleDefinition object (173) with 2 permissions
2024-04-24 11:57:29,382 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization Audit pk=RoleDefinition object (174) with 2 permissions
2024-04-24 11:57:29,386 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Inventory Admin pk=RoleDefinition object (175) with 6 permissions
2024-04-24 11:57:29,390 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization Inventory Admin pk=RoleDefinition object (176) with 8 permissions
2024-04-24 11:57:29,394 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Inventory Use pk=RoleDefinition object (177) with 2 permissions
2024-04-24 11:57:29,398 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Inventory Adhoc pk=RoleDefinition object (178) with 2 permissions
2024-04-24 11:57:29,402 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Credential Admin pk=RoleDefinition object (179) with 4 permissions
2024-04-24 11:57:29,406 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization Credential Admin pk=RoleDefinition object (180) with 6 permissions
2024-04-24 11:57:29,410 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Credential Use pk=RoleDefinition object (181) with 2 permissions
2024-04-24 11:57:29,414 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition InstanceGroup Admin pk=RoleDefinition object (182) with 4 permissions
2024-04-24 11:57:29,418 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization InstanceGroup Admin pk=RoleDefinition object (183) with 5 permissions
2024-04-24 11:57:29,422 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition InstanceGroup Use pk=RoleDefinition object (184) with 2 permissions
2024-04-24 11:57:29,426 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition ExecutionEnvironment Admin pk=RoleDefinition object (185) with 3 permissions
2024-04-24 11:57:29,430 INFO     [-] awx.main.migrations._dab_rbac Created RoleDefinition Organization ExecutionEnvironment Admin pk=RoleDefinition object (186) with 5 permissions
Traceback (most recent call last):
  File "/usr/bin/awx-manage", line 8, in <module>
    sys.exit(manage())
             ^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/awx/__init__.py", line 177, in manage
    execute_from_command_line(sys.argv)
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/var/lib/awx/venv/awx/lib64/python3.11/site-packages/awx/main/migrations/_dab_rbac.py", line 200, in migrate_to_new_rbac
    role_definition_name = f'{role.content_type.model_class().__name__} {action.title()}'
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ContentType' object has no attribute 'model_class'
  Applying main.0192_custom_roles...

AWX version

24.3.0

Select the relevant components

Installation method

kubernetes

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

upgrade ax-operator

Expected results

all working

Actual results

migration failed

Additional information

No response

NV-LijonFogel commented 1 week ago

Ah you have the same issue, I thought I was alone! I have commented on the PR from @AlanCoding which is responsible for that change.

Environment is external Postgres, but I guess this issue is Django related. Hope to see this fixed soon

josduppen commented 1 week ago

Same issue here as well

adpavlov commented 1 week ago

Ah you have the same issue, I thought I was alone! I have commented on the PR from @AlanCoding which is responsible for that change.

Environment is external Postgres, but I guess this issue is Django related. Hope to see this fixed soon

Yes, same issue. And one day I will hardcode awx and operator version and wait at least 2 weeks after new release, but not now:)

postgres is not external in my case, but I also don’t think it’s related.

Did a fallback to previous version and AWX came up.

NV-LijonFogel commented 1 week ago

Did a fallback to previous version and AWX came up.

Oh, how did you do that? I have deployed AWX via AWX-Operator as a subscirption and did not see an obvious way to downgrade. Also isn't the database incompatible now? A few migrations did run, so the tables are definitly altered.

kzinas-adv commented 1 week ago

Also upgrade to awx-migration-24.3.0 fail with same error:

AttributeError: 'ContentType' object has no attribute 'model_class'
  Applying main.0192_custom_roles...
ihriel commented 1 week ago

Same error here,

And like Adpavlov, my postgres is not external.

AlanCoding commented 1 week ago

Thank you for the report. I have put a patch up at https://github.com/ansible/awx/pull/15138 but it will take a while to fully verify it because the migration testing takes a while.

adpavlov commented 1 week ago

Thank you for the report. I have put a patch up at #15138 but it will take a while to fully verify it because the migration testing takes a while.

Probably mark current release as not good for installation?

adpavlov commented 1 week ago

Did a fallback to previous version and AWX came up.

Oh, how did you do that? I have deployed AWX via AWX-Operator as a subscirption and did not see an obvious way to downgrade. Also isn't the database incompatible now? A few migrations did run, so the tables are definitly altered.

Seems like data not affected much and back compatible. I have local installation and deploying operator as following:

    - name: Download and extract awx-operator into "{{ role_path }}/files"
      ansible.builtin.unarchive:
        src: "https://github.com/ansible/awx-operator/archive/{{ awx_operator_version }}.zip"
        dest: "{{ role_path }}/files"
        owner: "{{ devops.user.name }}"
        group: "{{ devops.user.group }}"
        mode: "0775"
        remote_src: true

    - name: Set DEFAULT_AWX_VERSION to {{ awx_version }} for awx-operator
      ansible.builtin.lineinfile:
        path: "{{ role_path }}/files/awx-operator-{{ awx_operator_version }}/config/manager/manager.yaml"
        regexp: '^.*{{ item }}.*$'
        line: '{{ item }}'
        insertafter: 'env:'
        firstmatch: true
        state: present
        backup: false
      loop:
        - '          value: {{ awx_version }}'
        - '        - name: DEFAULT_AWX_VERSION'
      loop_control:
        label: "Adding {{ item }}"

    - name: Deploy AWX Operator
      ansible.builtin.shell: |
        export DEFAULT_AWX_VERSION={{ awx_version }}
        make deploy
      args:
        chdir: "{{ role_path }}/files/awx-operator-{{ awx_operator_version }}"
      environment:
        PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
        NAMESPACE: awx
        VERSION: "{{ awx_operator_version }}"
        DEFAULT_AWX_VERSION: "{{ awx_version }}"
thedoubl3j commented 1 week ago

@adpavlov it will be marked as such shortly but not just for this issue, see also #15136

adpavlov commented 1 week ago

@adpavlov it will be marked as such shortly but not just for this issue, see also #15136

Haven’t reached this issue yet as failed in earlier step😂

AlanCoding commented 1 week ago

The patch for this issue is merged into the devel branch.

diarhussein commented 1 week ago

@AlanCoding Trying to deploy using helm install, but i still get the error. What can i do to make it work?

Nyralei commented 3 days ago

@adpavlov Try 24.3.1

adpavlov commented 2 days ago

@adpavlov Try 24.3.1

Migration passed fine. Thanks for the fix!