Skip to content
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

Use advisory_lock from DAB #15676

Open
wants to merge 7 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Check warning on line 7 in awx/main/management/commands/deprovision_instance.py

View check run for this annotation

Codecov / codecov/patch

awx/main/management/commands/deprovision_instance.py#L7

Added line #L7 was not covered by tests

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

Check warning on line 5 in awx/main/management/commands/unregister_queue.py

View check run for this annotation

Codecov / codecov/patch

awx/main/management/commands/unregister_queue.py#L5

Added line #L5 was not covered by tests

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 @@ -23,9 +23,11 @@


# 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
2 changes: 1 addition & 1 deletion awx/main/tasks/host_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from awx.main.models.inventory import HostMetric, HostMetricSummaryMonthly
from awx.main.tasks.helpers import is_run_threshold_reached
from awx.conf.license import get_license
from awx.main.utils.pglock import advisory_lock
from ansible_base.lib.utils.db import advisory_lock


logger = logging.getLogger('awx.main.tasks.host_metrics')
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.

3 changes: 0 additions & 3 deletions licenses/django-pglocks.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ django-extensions
django-guid
django-oauth-toolkit<2.0.0 # Version 2.0.0 has breaking changes that will need to be worked out before upgrading
django-polymorphic
django-pglocks
django-solo
django-split-settings
djangorestframework>=3.15.0
Expand Down
3 changes: 0 additions & 3 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ django-guid==3.5.0
# via -r /awx_devel/requirements/requirements.in
django-oauth-toolkit==1.7.1
# via -r /awx_devel/requirements/requirements.in
django-pglocks==1.0.4
# via -r /awx_devel/requirements/requirements.in
django-polymorphic==3.1.0
# via -r /awx_devel/requirements/requirements.in
django-solo==2.4.0
Expand Down Expand Up @@ -456,7 +454,6 @@ setuptools-scm[toml]==8.1.0
six==1.17.0
# via
# azure-core
# django-pglocks
# kubernetes
# msrestazure
# openshift
Expand Down
Loading