mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 17:17:45 -02:30
create lock for perform_update
* perform_update can be called from either awx-manage or the RunInventoryUpdate task * need to make sure that the inventory updates that happen with perform_update are atomic
This commit is contained in:
@@ -863,6 +863,7 @@ class Command(BaseCommand):
|
||||
self.inventory_update.save(update_fields=['org_host_limit_error'])
|
||||
|
||||
def handle(self, *args, **options):
|
||||
with advisory_lock('inventory_{}_import'.format(self.inventory.id)):
|
||||
# Load inventory and related objects from database.
|
||||
inventory_name = options.get('inventory_name', None)
|
||||
inventory_id = options.get('inventory_id', None)
|
||||
@@ -966,7 +967,12 @@ class Command(BaseCommand):
|
||||
raise CommandError('invalid regular expression for --host-filter')
|
||||
|
||||
begin = time.time()
|
||||
with advisory_lock('inventory_{}_update'.format(self.inventory.id)):
|
||||
|
||||
# Since perform_update can be invoked either through the awx-manage CLI
|
||||
# or from the task system, we need to create a new lock at this level
|
||||
# (even though inventory_import.Command.handle -- which calls
|
||||
# perform_update -- has its own lock, inventory_ID_import)
|
||||
with advisory_lock('inventory_{}_perform_update'.format(self.inventory.id)):
|
||||
|
||||
try:
|
||||
self.check_license()
|
||||
|
||||
Reference in New Issue
Block a user