From b24156805a242416aecec849e435faa87eb36d00 Mon Sep 17 00:00:00 2001 From: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Date: Wed, 3 Dec 2025 14:22:52 -0500 Subject: [PATCH] Upgrade to Django 5.2 LTS (#16185) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upgrade to Django 5.2 LTS with compatibility fixes across fields, migrations, dispatch config, tests, and dev deps. Dependencies: - Upgrade django to 5.2.8 and relax requirements.in to >=5.2,<5.3. - Bump django-debug-toolbar to >=6.0 for compatibility. Backend: - awx/conf/fields.py: switch URL TLD regex to use DomainNameValidator.ul in custom URLField. - awx/main/management/commands/gather_analytics.py: use datetime.timezone.utc for naïve datetime handling. - awx/main/dispatch/config.py: add mock_publish option; avoid DB access for test runs, set default max_workers, and support a noop broker. Migrations (SQLite/Postgres compatibility): - Add awx/main/migrations/_sqlite_helper.py with db-aware AlterIndexTogether/RenameIndex wrappers; consume in 0144_event_partitions.py and 0184_django_indexes.py. - Update 0187_hop_nodes.py to use CheckConstraint(condition=...). - Add 0205_alter_instance_peers_alter_job_hosts_and_more.py adjusting through_fields/relations on instance.peers, job.hosts, and role.ancestors. - _dab_rbac.py: iterate roles with chunk_size=1000 for migration performance. Tests: Include hcp_terraform in default credential types in test_credential.py. --------- Co-authored-by: Claude Co-authored-by: Alan Rominger --- awx/conf/fields.py | 5 +- awx/main/dispatch/config.py | 11 ++- .../management/commands/gather_analytics.py | 6 +- awx/main/migrations/0144_event_partitions.py | 10 +-- awx/main/migrations/0184_django_indexes.py | 38 +++++----- awx/main/migrations/0187_hop_nodes.py | 2 +- ...instance_peers_alter_job_hosts_and_more.py | 32 ++++++++ awx/main/migrations/_dab_rbac.py | 2 +- awx/main/migrations/_sqlite_helper.py | 74 +++++++++++++++++++ requirements/requirements.in | 2 +- requirements/requirements.txt | 2 +- requirements/requirements_dev.txt | 3 +- 12 files changed, 152 insertions(+), 35 deletions(-) create mode 100644 awx/main/migrations/0205_alter_instance_peers_alter_job_hosts_and_more.py diff --git a/awx/conf/fields.py b/awx/conf/fields.py index 3296c29c04..ae809ca9b6 100644 --- a/awx/conf/fields.py +++ b/awx/conf/fields.py @@ -6,7 +6,7 @@ import urllib.parse as urlparse from collections import OrderedDict # Django -from django.core.validators import URLValidator, _lazy_re_compile +from django.core.validators import URLValidator, DomainNameValidator, _lazy_re_compile from django.utils.translation import gettext_lazy as _ # Django REST Framework @@ -160,10 +160,11 @@ class StringListIsolatedPathField(StringListField): class URLField(CharField): # these lines set up a custom regex that allow numbers in the # top-level domain + tld_re = ( r'\.' # dot r'(?!-)' # can't start with a dash - r'(?:[a-z' + URLValidator.ul + r'0-9' + '-]{2,63}' # domain label, this line was changed from the original URLValidator + r'(?:[a-z' + DomainNameValidator.ul + r'0-9' + '-]{2,63}' # domain label, this line was changed from the original URLValidator r'|xn--[a-z0-9]{1,59})' # or punycode label r'(?=5.2,<5.3 # Django 5.2 LTS, allow patch updates django-cors-headers django-crum django-extensions diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 3e65649908..f88df90e25 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -124,7 +124,7 @@ dispatcherd==2025.5.21 # via -r /awx_devel/requirements/requirements.in distro==1.9.0 # via -r /awx_devel/requirements/requirements.in -django==4.2.26 +django==5.2.8 # via # -r /awx_devel/requirements/requirements.in # channels diff --git a/requirements/requirements_dev.txt b/requirements/requirements_dev.txt index 92ef46f576..7c6a84ceb3 100644 --- a/requirements/requirements_dev.txt +++ b/requirements/requirements_dev.txt @@ -1,5 +1,5 @@ build -django-debug-toolbar==3.2.4 +django-debug-toolbar>=6.0 # Django 5.2 compatibility django-test-migrations drf-spectacular>=0.27.0 # Modern OpenAPI 3.0 schema generator # pprofile - re-add once https://github.com/vpelletier/pprofile/issues/41 is addressed @@ -28,4 +28,3 @@ pip>=21.3,<=24.0 # PEP 660 – Editable installs for pyproject.toml based builds debugpy remote-pdb sdb -