-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Upgrade to Django 5.2 LTS #16185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to Django 5.2 LTS #16185
Conversation
This commit upgrades AWX from Django 4.2.26 to Django 5.2 (LTS). Changes: - Update Django to 5.2 LTS with proper version constraints (>=5.2,<5.3) to allow automatic patch updates while preventing breaking changes - Fix URLValidator.ul compatibility issue for Django 5.2 (Django removed the 'ul' attribute, now using explicit unicode range) - Upgrade django-debug-toolbar to >=6.0 for Django 5.2 compatibility (required for removal of get_storage_class) - Add migration for Django 5.2 ManyToManyField representation changes (no schema changes, only internal Django representation updates) All tests passing with Django 5.2.8 installed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Added a check to avoid running dispatcher configuration in Django app initialization when pytest is present. This prevents database access errors during test runs, aligning with Django 5.2+ stricter initialization rules.
Dispatcherd configuration requires database access to query settings, but pytest-django blocks database access during app initialization (before the test database is created). Solution: - Skip dispatcherd configuration in MainConfig.ready() when pytest is loaded - Add autouse session-scoped fixture that configures dispatcherd after the test database is ready This resolves the "Dispatcherd not configured" RuntimeError in tests that use TaskManager().schedule(). Note: Django 5.2 shows a RuntimeWarning about database access during app initialization in non-test environments, but this is just a warning and doesn't break functionality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
awx/conf/fields.py
Outdated
| # these lines set up a custom regex that allow numbers in the | ||
| # top-level domain | ||
| # Django 5.2 removed URLValidator.ul, it was \u00a1-\uffff for unicode letters | ||
| ul = r'\u00a1-\uffff' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Broken regex allowing invalid domain characters
Defining ul as a raw string r'\u00a1-\uffff' prevents Python from decoding the unicode escapes. The regex engine interprets this as literal characters, creating an unintended range from 1 to \ that accepts uppercase letters and symbols like @, while failing to match valid unicode characters. Remove the r prefix.
Removes test-specific logic from MainConfig.ready() and the test fixture that delayed dispatcherd configuration until after the test database was ready. Instead, dispatcherd config now supports a mock_publish flag to avoid database queries during tests, simplifying initialization and improving test reliability.
|
Only 1 test failed |
| # When mock_publish=True (e.g., during tests), use a default value to avoid | ||
| # database access in get_auto_max_workers() which queries settings.IS_K8S | ||
| if mock_publish: | ||
| max_workers = 20 # Reasonable default for tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...sure
| migrations.AlterField( | ||
| model_name='role', | ||
| name='ancestors', | ||
| field=models.ManyToManyField( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this in other libraries, I expect it to be a no-op
Add chunk_size parameter to iterator() call when using prefetch_related() as required by Django 5.2. This resolves the migration failure: "ValueError: chunk_size must be provided when using QuerySet.iterator() after prefetch_related()." Fixes the dev-env CI failure where AWX container failed to start due to this migration error during database initialization. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| 'gpg_public_key', | ||
| 'hashivault_kv', | ||
| 'hashivault_ssh', | ||
| 'hcp_terraform', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unrelated credential type added to test
The test adds 'hcp_terraform' to the expected credential types list, but this credential type doesn't appear to be defined anywhere in the codebase. This is unrelated to the Django 5.2 upgrade and causes test_default_cred_types to fail, as mentioned in the PR discussion. The credential type definition needs to be added before updating the test expectations, or this line should be removed if the feature isn't ready yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that cred in awx-plugins?
Update migration 0187 to use 'condition' parameter instead of deprecated 'check' parameter in CheckConstraint, addressing Django 5.2 compatibility warning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
15e61f1 to
4432f49
Compare
- Gate the SQLite schema-editor monkeypatch behind AWX_MIGRATION_TESTS so only migration smoke tests use it. - Align all patched methods to ignore missing constraint/index ValueErrors caused by SQLite table rewrites. - Leave default test runs untouched.
df720bf to
0cfc8e1
Compare
Replace deprecated django.utils.timezone.utc with datetime.timezone.utc to fix AttributeError when running the gather_analytics management command. Django 5.0+ removed timezone.utc in favor of Python's standard library. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Replace hardcoded unicode letter range with DomainNameValidator.ul for better maintainability and to avoid duplication. Co-Authored-By: Alan Rominger <[email protected]>
…0184 In Django 5.2+, SQLite table rewrites drop multi-column indexes, causing AlterIndexTogether and RenameIndex operations to fail when trying to modify indexes that no longer exist. Changes: - Add database-aware AlterIndexTogether and RenameIndex to _sqlite_helper.py - Update migration 0144 to use dbawaremigrations.AlterIndexTogether (5 operations) - Update migration 0184 to use dbawaremigrations.RenameIndex (18 operations) - Remove schema editor monkeypatch from settings_for_test.py - Remove AWX_MIGRATION_TESTS environment variable from Makefile The new operations check the database vendor and apply SQLite-specific error handling that ignores missing indexes, while using standard behavior for PostgreSQL. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
AlanCoding
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing up the migrations for sqlite3, I do have hopes that still runs to completion after work @chrismeyersfsu previously did


ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
Note
Upgrade to Django 5.2 LTS with compatibility fixes across fields, migrations, dispatch config, tests, and dev deps.
djangoto5.2.8and relaxrequirements.into>=5.2,<5.3.django-debug-toolbarto>=6.0for compatibility.awx/conf/fields.py: switch URL TLD regex to useDomainNameValidator.ulin customURLField.awx/main/management/commands/gather_analytics.py: usedatetime.timezone.utcfor naïve datetime handling.awx/main/dispatch/config.py: addmock_publishoption; avoid DB access for test runs, set defaultmax_workers, and support anoopbroker.awx/main/migrations/_sqlite_helper.pywith db-awareAlterIndexTogether/RenameIndexwrappers; consume in0144_event_partitions.pyand0184_django_indexes.py.0187_hop_nodes.pyto useCheckConstraint(condition=...).0205_alter_instance_peers_alter_job_hosts_and_more.pyadjustingthrough_fields/relations oninstance.peers,job.hosts, androle.ancestors._dab_rbac.py: iterate roles withchunk_size=1000for migration performance.hcp_terraformin default credential types intest_credential.py.Written by Cursor Bugbot for commit 0fff088. This will update automatically on new commits. Configure here.