Skip to content

Commit

Permalink
Merge branch 'devel' into typeerror-py3.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloHiro authored Jan 29, 2025
2 parents 975df2b + c6930bd commit 71a9b52
Show file tree
Hide file tree
Showing 136 changed files with 2,020 additions and 1,325 deletions.
4 changes: 2 additions & 2 deletions .github/actions/upload_awx_devel_logs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
docker logs tools_awx_1 > ${{ inputs.log-filename }}
- name: Upload AWX logs as artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: docker-compose-logs
name: docker-compose-logs-${{ inputs.log-filename }}
path: ${{ inputs.log-filename }}
28 changes: 19 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ jobs:

- name: Upload debug output
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: awx-operator-debug-output
path: ${{ env.DEBUG_OUTPUT_DIR }}
Expand Down Expand Up @@ -328,7 +328,7 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}

# Upload coverage report as artifact
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-${{ matrix.target-regex.name }}
Expand Down Expand Up @@ -359,19 +359,29 @@ jobs:
- name: Upgrade ansible-core
run: python3 -m pip install --upgrade ansible-core

- name: Download coverage artifacts
uses: actions/download-artifact@v3
- name: Download coverage artifacts A to H
uses: actions/download-artifact@v4
with:
name: coverage-a-h
path: coverage

- name: Download coverage artifacts I to P
uses: actions/download-artifact@v4
with:
name: coverage-i-p
path: coverage

- name: Download coverage artifacts Z to Z
uses: actions/download-artifact@v4
with:
name: coverage-r-z0-9
path: coverage

- name: Combine coverage
run: |
make COLLECTION_VERSION=100.100.100-git install_collection
mkdir -p ~/.ansible/collections/ansible_collections/awx/awx/tests/output/coverage
cd coverage
for i in coverage-*; do
cp -rv $i/* ~/.ansible/collections/ansible_collections/awx/awx/tests/output/coverage/
done
cp -rv coverage/* ~/.ansible/collections/ansible_collections/awx/awx/tests/output/coverage/
cd ~/.ansible/collections/ansible_collections/awx/awx
ansible-test coverage combine --requirements
ansible-test coverage html
Expand Down Expand Up @@ -424,7 +434,7 @@ jobs:
done
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: awx-collection-integration-coverage-html
path: ~/.ansible/collections/ansible_collections/awx/awx/tests/output/reports/coverage
17 changes: 1 addition & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ RECEPTOR_IMAGE ?= quay.io/ansible/receptor:devel
SRC_ONLY_PKGS ?= cffi,pycparser,psycopg,twilio
# These should be upgraded in the AWX and Ansible venv before attempting
# to install the actual requirements
VENV_BOOTSTRAP ?= pip==21.2.4 setuptools==69.0.2 setuptools_scm[toml]==8.0.4 wheel==0.42.0 cython==0.29.37
VENV_BOOTSTRAP ?= pip==21.2.4 setuptools==70.3.0 setuptools_scm[toml]==8.1.0 wheel==0.45.1 cython==3.0.11

NAME ?= awx

Expand Down Expand Up @@ -589,24 +589,9 @@ docker-clean-volumes: docker-compose-clean docker-compose-container-group-clean

docker-refresh: docker-clean docker-compose

## Docker Development Environment with Elastic Stack Connected
docker-compose-elk: awx/projects docker-compose-sources
$(DOCKER_COMPOSE) -f tools/docker-compose/_sources/docker-compose.yml -f tools/elastic/docker-compose.logstash-link.yml -f tools/elastic/docker-compose.elastic-override.yml up --no-recreate

docker-compose-cluster-elk: awx/projects docker-compose-sources
$(DOCKER_COMPOSE) -f tools/docker-compose/_sources/docker-compose.yml -f tools/elastic/docker-compose.logstash-link-cluster.yml -f tools/elastic/docker-compose.elastic-override.yml up --no-recreate

docker-compose-container-group:
MINIKUBE_CONTAINER_GROUP=true $(MAKE) docker-compose

clean-elk:
docker stop tools_kibana_1
docker stop tools_logstash_1
docker stop tools_elasticsearch_1
docker rm tools_logstash_1
docker rm tools_elasticsearch_1
docker rm tools_kibana_1

VERSION:
@echo "awx: $(VERSION)"

Expand Down
4 changes: 2 additions & 2 deletions awx/api/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ def get_view_description(view, html=False):

def get_default_schema():
if settings.SETTINGS_MODULE == 'awx.settings.development':
from awx.api.swagger import AutoSchema
from awx.api.swagger import schema_view

return AutoSchema()
return schema_view
else:
return views.APIView.schema

Expand Down
64 changes: 28 additions & 36 deletions awx/api/swagger.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,54 @@
import warnings

from rest_framework.permissions import AllowAny
from rest_framework.schemas import SchemaGenerator, AutoSchema as DRFAuthSchema

from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from drf_yasg.inspectors import SwaggerAutoSchema
from drf_yasg.views import get_schema_view


class SuperUserSchemaGenerator(SchemaGenerator):
def has_view_permissions(self, path, method, view):
#
# Generate the Swagger schema as if you were a superuser and
# permissions didn't matter; this short-circuits the schema path
# discovery to include _all_ potential paths in the API.
#
return True

class CustomSwaggerAutoSchema(SwaggerAutoSchema):
"""Custom SwaggerAutoSchema to add swagger_topic to tags."""

class AutoSchema(DRFAuthSchema):
def get_link(self, path, method, base_url):
link = super(AutoSchema, self).get_link(path, method, base_url)
def get_tags(self, operation_keys=None):
tags = []
try:
serializer = self.view.get_serializer()
if hasattr(self.view, 'get_serializer'):
serializer = self.view.get_serializer()
else:
serializer = None
except Exception:
serializer = None
warnings.warn(
'{}.get_serializer() raised an exception during '
'schema generation. Serializer fields will not be '
'generated for {} {}.'.format(self.view.__class__.__name__, method, path)
'generated for {}.'.format(self.view.__class__.__name__, operation_keys)
)

link.__dict__['deprecated'] = getattr(self.view, 'deprecated', False)

# auto-generate a topic/tag for the serializer based on its model
if hasattr(self.view, 'swagger_topic'):
link.__dict__['topic'] = str(self.view.swagger_topic).title()
tags.append(str(self.view.swagger_topic).title())
elif serializer and hasattr(serializer, 'Meta'):
link.__dict__['topic'] = str(serializer.Meta.model._meta.verbose_name_plural).title()
tags.append(str(serializer.Meta.model._meta.verbose_name_plural).title())
elif hasattr(self.view, 'model'):
link.__dict__['topic'] = str(self.view.model._meta.verbose_name_plural).title()
tags.append(str(self.view.model._meta.verbose_name_plural).title())
else:
warnings.warn('Could not determine a Swagger tag for path {}'.format(path))
return link
tags = ['api'] # Fallback to default value

if not tags:
warnings.warn(f'Could not determine tags for {self.view.__class__.__name__}')
return tags

def get_description(self, path, method):
setattr(self.view.request, 'swagger_method', method)
description = super(AutoSchema, self).get_description(path, method)
return description
def is_deprecated(self):
"""Return `True` if this operation is to be marked as deprecated."""
return getattr(self.view, 'deprecated', False)


schema_view = get_schema_view(
openapi.Info(
title="Snippets API",
default_version='v1',
description="Test description",
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="[email protected]"),
license=openapi.License(name="BSD License"),
title='AWX API',
default_version='v2',
description='AWX API Documentation',
terms_of_service='https://www.google.com/policies/terms/',
contact=openapi.Contact(email='[email protected]'),
license=openapi.License(name='Apache License'),
),
public=True,
permission_classes=[AllowAny],
Expand Down
4 changes: 3 additions & 1 deletion awx/main/analytics/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
import requests

from awx.conf.license import get_license

from ansible_base.lib.utils.db import advisory_lock

from awx.main.models import Job
from awx.main.access import access_registry
from awx.main.utils import get_awx_http_client_headers, set_environ, datetime_hook
from awx.main.utils.pglock import advisory_lock

__all__ = ['register', 'gather', 'ship']

Expand Down
3 changes: 3 additions & 0 deletions awx/main/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def _load_credential_types_feature(self):

@bypass_in_test
def load_credential_types_feature(self):
from awx.main.models.credential import load_credentials

load_credentials()
return self._load_credential_types_feature()

def load_inventory_plugins(self):
Expand Down
2 changes: 1 addition & 1 deletion awx/main/dispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def current_notifies(conn):
ns = conn.wait(psycopg.generators.notifies(conn.pgconn))
except psycopg.errors._NO_TRACEBACK as ex:
raise ex.with_traceback(None)
enc = psycopg._encodings.pgconn_encoding(conn.pgconn)
for pgn in ns:
enc = conn.pgconn._encoding
n = psycopg.connection.Notify(pgn.relname.decode(enc), pgn.extra.decode(enc), pgn.be_pid)
yield n

Expand Down
2 changes: 1 addition & 1 deletion awx/main/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ def schema(self, model_instance):
'type': 'string',
# The environment variable _value_ can be any ascii,
# but pexpect will choke on any unicode
'pattern': '^[\x00-\x7F]*$',
'pattern': '^[\x00-\x7f]*$',
},
},
'additionalProperties': False,
Expand Down
3 changes: 2 additions & 1 deletion awx/main/management/commands/deprovision_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from django.db import transaction
from django.core.management.base import BaseCommand, CommandError

from ansible_base.lib.utils.db import advisory_lock

from awx.main.models import Instance
from awx.main.utils.pglock import advisory_lock


class Command(BaseCommand):
Expand Down
4 changes: 3 additions & 1 deletion awx/main/management/commands/inventory_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
# DRF error class to distinguish license exceptions
from rest_framework.exceptions import PermissionDenied

# django-ansible-base
from ansible_base.lib.utils.db import advisory_lock

# AWX inventory imports
from awx.main.models.inventory import Inventory, InventorySource, InventoryUpdate, Host
from awx.main.utils.mem_inventory import MemInventory, dict_to_mem_data
Expand All @@ -32,7 +35,6 @@
from awx.main.utils.execution_environments import get_default_execution_environment
from awx.main.signals import disable_activity_stream
from awx.main.constants import STANDARD_INVENTORY_UPDATE_ENV
from awx.main.utils.pglock import advisory_lock

logger = logging.getLogger('awx.main.commands.inventory_import')

Expand Down
3 changes: 2 additions & 1 deletion awx/main/management/commands/register_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# All Rights Reserved.
import sys

from awx.main.utils.pglock import advisory_lock
from ansible_base.lib.utils.db import advisory_lock

from awx.main.models import Instance, InstanceGroup

from django.core.management.base import BaseCommand, CommandError
Expand Down
3 changes: 2 additions & 1 deletion awx/main/management/commands/unregister_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# All Rights Reserved.
import sys

from awx.main.utils.pglock import advisory_lock
from ansible_base.lib.utils.db import advisory_lock

from awx.main.models import InstanceGroup

from django.db import transaction
Expand Down
4 changes: 3 additions & 1 deletion awx/main/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
from django.db import models
from django.conf import settings
from django.db.models.functions import Lower

from ansible_base.lib.utils.db import advisory_lock

from awx.main.utils.filters import SmartFilter
from awx.main.utils.pglock import advisory_lock
from awx.main.constants import RECEPTOR_PENDING

___all__ = ['HostManager', 'InstanceManager', 'DeferJobCreatedManager', 'UUID_DEFAULT']
Expand Down
4 changes: 2 additions & 2 deletions awx/main/migrations/0050_v340_drop_celery_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
'djkombu_message',
'djkombu_queue',
]
postgres_sql = ([("DROP TABLE IF EXISTS {} CASCADE;".format(table))] for table in tables_to_drop)
sqlite_sql = ([("DROP TABLE IF EXISTS {};".format(table))] for table in tables_to_drop)
postgres_sql = (["DROP TABLE IF EXISTS {} CASCADE;".format(table)] for table in tables_to_drop)
sqlite_sql = (["DROP TABLE IF EXISTS {};".format(table)] for table in tables_to_drop)


class Migration(migrations.Migration):
Expand Down
4 changes: 2 additions & 2 deletions awx/main/migrations/0078_v360_clear_sessions_tokens_jt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import unicode_literals

from django.db import migrations, models
from awx.main.migrations._create_system_jobs import create_clearsessions_jt, create_cleartokens_jt
from awx.main.migrations._create_system_jobs import create_clearsessions_jt


class Migration(migrations.Migration):
Expand All @@ -14,7 +14,7 @@ class Migration(migrations.Migration):
operations = [
# Schedule Analytics System Job Template
migrations.RunPython(create_clearsessions_jt, migrations.RunPython.noop),
migrations.RunPython(create_cleartokens_jt, migrations.RunPython.noop),
# previously ran create_cleartokens_jt, logic for this has been removed
migrations.AlterField(
model_name='systemjob',
name='job_type',
Expand Down
44 changes: 44 additions & 0 deletions awx/main/migrations/0200_delete_token_cleanup_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 4.2.16 on 2024-12-18 16:05

from django.db import migrations, models

from awx.main.migrations._create_system_jobs import delete_clear_tokens_sjt


class Migration(migrations.Migration):

dependencies = [
('main', '0199_alter_oauth2application_unique_together_and_more'),
]

operations = [
migrations.RunPython(delete_clear_tokens_sjt, migrations.RunPython.noop),
migrations.AlterField(
model_name='systemjob',
name='job_type',
field=models.CharField(
blank=True,
choices=[
('cleanup_jobs', 'Remove jobs older than a certain number of days'),
('cleanup_activitystream', 'Remove activity stream entries older than a certain number of days'),
('cleanup_sessions', 'Removes expired browser sessions from the database'),
],
default='',
max_length=32,
),
),
migrations.AlterField(
model_name='systemjobtemplate',
name='job_type',
field=models.CharField(
blank=True,
choices=[
('cleanup_jobs', 'Remove jobs older than a certain number of days'),
('cleanup_activitystream', 'Remove activity stream entries older than a certain number of days'),
('cleanup_sessions', 'Removes expired browser sessions from the database'),
],
default='',
max_length=32,
),
),
]
Loading

0 comments on commit 71a9b52

Please sign in to comment.