Skip to content

Commit

Permalink
Use advisory_lock from DAB
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Dec 2, 2024
1 parent c64b5eb commit b8a4694
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 40 deletions.
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: 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: 3 additions & 1 deletion awx/main/models/credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
from awx_plugins.interfaces._temporary_private_container_api import get_incontainer_path

# DRF
from awx.main.utils.pglock import advisory_lock
from rest_framework.serializers import ValidationError as DRFValidationError

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

# AWX
from awx.api.versioning import reverse
from awx.main.fields import (
Expand Down
4 changes: 3 additions & 1 deletion awx/main/scheduler/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

from ansible_base.lib.utils.models import get_type_for_model

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

# AWX
from awx.main.dispatch.reaper import reap_job
from awx.main.models import (
Expand All @@ -34,7 +37,6 @@
WorkflowJobTemplate,
)
from awx.main.scheduler.dag_workflow import WorkflowDAG
from awx.main.utils.pglock import advisory_lock
from awx.main.utils import (
ScheduleTaskManager,
ScheduleWorkflowManager,
Expand Down
4 changes: 3 additions & 1 deletion awx/main/tasks/receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
# Runner
import ansible_runner

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

# AWX
from awx.main.utils.execution_environments import get_default_pod_spec
from awx.main.exceptions import ReceptorNodeNotFound
Expand All @@ -30,7 +33,6 @@
from awx.main.models import Instance, InstanceLink, UnifiedJob, ReceptorAddress
from awx.main.dispatch import get_task_queuename
from awx.main.dispatch.publish import task
from awx.main.utils.pglock import advisory_lock

# Receptorctl
from receptorctl.socket_interface import ReceptorControl
Expand Down
2 changes: 1 addition & 1 deletion awx/main/tasks/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

# django-ansible-base
from ansible_base.resource_registry.tasks.sync import SyncExecutor
from ansible_base.lib.utils.db import advisory_lock

# AWX
from awx import __version__ as awx_application_version
Expand All @@ -60,7 +61,6 @@
from awx.main.utils.common import ignore_inventory_computed_fields, ignore_inventory_group_removal

from awx.main.utils.reload import stop_local_services
from awx.main.utils.pglock import advisory_lock
from awx.main.tasks.helpers import is_run_threshold_reached
from awx.main.tasks.receptor import get_receptor_ctl, worker_info, worker_cleanup, administrative_workunit_reaper, write_receptor_config
from awx.main.consumers import emit_channel_notification
Expand Down
29 changes: 0 additions & 29 deletions awx/main/utils/pglock.py

This file was deleted.

2 changes: 1 addition & 1 deletion requirements/requirements_git.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
git+https://github.com/ansible/system-certifi.git@devel#egg=certifi
# Remove pbr from requirements.in when moving ansible-runner to requirements.in
git+https://github.com/ansible/ansible-runner.git@devel#egg=ansible-runner
django-ansible-base @ git+https://github.com/ansible/django-ansible-base@devel#egg=django-ansible-base[rest-filters,jwt_consumer,resource-registry,rbac]
django-ansible-base @ git+https://github.com/alancoding/django-ansible-base@advisory_lock#egg=django-ansible-base[rest-filters,jwt_consumer,resource-registry,rbac]
awx-plugins-core @ git+https://[email protected]/ansible/awx-plugins.git@devel#egg=awx-plugins-core
awx_plugins.interfaces @ git+https://github.com/ansible/awx_plugins.interfaces.git

0 comments on commit b8a4694

Please sign in to comment.