Skip to content

[bug] Celery worker skips execution of update_config task due to incorrect self-detection #1204

@pandafy

Description

@pandafy

Describe the bug
When the celery worker executes openwisp_controller.connection.tasks.update_config, it incorrectly detects that another worker is executing the task, when in reality it is the same worker running it. As a result, the worker returns early, skipping the actual execution even though it is the correct one to run the task.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Change the configuration of device (e.g. change name or configuration)
  2. Observe the log/output during the task's execution from the celery worker.
  3. Notice that the task exits/returns early, incorrectly assuming another worker is executing it, despite being run by the current worker itself.

Expected behavior
The celery worker should correctly detect if another worker is running the task, and should proceed with execution when it is indeed the task's actual worker.

def _is_update_in_progress(device_id):
active = current_app.control.inspect().active()
if not active:
return False
# check if there's any other running task before adding it
for task_list in active.values():
for task in task_list:
if task["name"] == _TASK_NAME and str(device_id) in task["args"]:
return True
return False

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions