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

Problems with Celery #5406

Closed
evilmonkey19 opened this issue Mar 8, 2024 · 3 comments
Closed

Problems with Celery #5406

evilmonkey19 opened this issue Mar 8, 2024 · 3 comments
Labels
question Further information is requested triage This issue is new and has not been reviewed. type: bug Something isn't working as expected

Comments

@evilmonkey19
Copy link

Environment

  • Nautobot version (Docker tag too if applicable): nautobot:stable-py3.11
  • Python version: 3.11
  • Database platform, version: postgres:13
  • Middleware(s): default

Steps to Reproduce

  1. I have create this job in the root folder for jobs (/opt/nautobot/jobs:

## Tutorial: https://josh-v.com/nautobot-jobs-in-jobs-root/
from django.conf import settings

from nautobot.dcim.models import Device

from nautobot.apps.jobs import Job, ObjectVar, register_jobs

from netmiko import ConnectHandler

name = "Get Version Huawei Smartax EA5800"

class GetVersionOLT(Job):
    device = ObjectVar(
        model=Device,
        description="Device to get the version of"
    )

    def run(self, device):
        self.log_debug(device)
    
    class Meta:
        name = "Get Version OLT"
        description = "Get the version of the OLT"


register_jobs(GetVersionOLT)
  1. I do the nautobot-server post_upgrade and restart the dockers for nautobot, celery_worker and celery_beat
  2. I try to run the job create

Expected Behavior

It should run the job without any major issue, printing the data from the device.

Observed Behavior

It crashed the celery_worker saying the following:

2024-03-08 14:54:08 [2024-03-08 13:54:08,522: WARNING/MainProcess] /usr/local/lib/python3.11/site-packages/celery/worker/consumer/consumer.py:507: CPendingDeprecationWarning: The broker_connection_retry configuration setting will no longer determine
2024-03-08 14:54:08 whether broker connection retries are made during startup in Celery 6.0 and above.
2024-03-08 14:54:08 If you wish to retain the existing behavior for retrying connections on startup,
2024-03-08 14:54:08 you should set broker_connection_retry_on_startup to True.
2024-03-08 14:54:08   warnings.warn(
2024-03-08 14:54:08 
2024-03-08 14:54:08 [2024-03-08 13:54:08,536: WARNING/MainProcess] /usr/local/lib/python3.11/site-packages/celery/worker/consumer/consumer.py:507: CPendingDeprecationWarning: The broker_connection_retry configuration setting will no longer determine
2024-03-08 14:54:08 whether broker connection retries are made during startup in Celery 6.0 and above.
2024-03-08 14:54:08 If you wish to retain the existing behavior for retrying connections on startup,
2024-03-08 14:54:08 you should set broker_connection_retry_on_startup to True.
2024-03-08 14:54:08   warnings.warn(
2024-03-08 14:54:08 
2024-03-08 14:55:11 [2024-03-08 13:55:11,472: ERROR/MainProcess] Received unregistered task of type 'get_version_olt_jobs.GetVersionOLT'.
2024-03-08 14:55:11 The message has been ignored and discarded.
2024-03-08 14:55:11 
2024-03-08 14:55:11 Did you remember to import the module containing this task?
2024-03-08 14:55:11 Or maybe you're using relative imports?
2024-03-08 14:55:11 
2024-03-08 14:55:11 Please see
2024-03-08 14:55:11 https://docs.celeryq.dev/en/latest/internals/protocol.html
2024-03-08 14:55:11 for more information.
2024-03-08 14:55:11 
2024-03-08 14:55:11 The full contents of the message body was:
2024-03-08 14:55:11 b'[[], {"device": "c2c05bf8-bd96-4c5c-8545-425504323d35"}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]' (125b)
2024-03-08 14:55:11 
2024-03-08 14:55:11 The full contents of the message headers:
2024-03-08 14:55:11 {'lang': 'py', 'task': 'get_version_olt_jobs.GetVersionOLT', 'id': '7aaae6da-91af-414e-8a48-6d2b3eb20699', 'shadow': None, 'eta': None, 'expires': None, 'group': None, 'group_index': None, 'retries': 0, 'timelimit': [0, 0], 'root_id': '7aaae6da-91af-414e-8a48-6d2b3eb20699', 'parent_id': None, 'argsrepr': '()', 'kwargsrepr': "{'device': UUID('c2c05bf8-bd96-4c5c-8545-425504323d35')}", 'origin': 'gen74@51696c90f8fb', 'ignore_result': False, 'replaced_task_nesting': 0, 'stamped_headers': None, 'stamps': {}}
2024-03-08 14:55:11 
2024-03-08 14:55:11 The delivery info for this task is:
2024-03-08 14:55:11 {'exchange': '', 'routing_key': 'default'}
2024-03-08 14:55:11 Traceback (most recent call last):
2024-03-08 14:55:11   File "/usr/local/lib/python3.11/site-packages/celery/worker/consumer/consumer.py", line 658, in on_task_received
2024-03-08 14:55:11     strategy = strategies[type_]
2024-03-08 14:55:11                ~~~~~~~~~~^^^^^^^
2024-03-08 14:55:11 KeyError: 'get_version_olt_jobs.GetVersionOLT'
2024-03-08 14:55:11 [2024-03-08 13:55:11,475: CRITICAL/MainProcess] Unrecoverable error: AttributeError("'Bunch' object has no attribute 'delivery_info'")
@evilmonkey19 evilmonkey19 added triage This issue is new and has not been reviewed. type: bug Something isn't working as expected labels Mar 8, 2024
@glennmatthews
Copy link
Contributor

glennmatthews commented Mar 8, 2024

Is /opt/nautobot/jobs/get_version_olt_jobs.py present in both the server container and the celery worker container?

@glennmatthews glennmatthews added the question Further information is requested label Mar 8, 2024
@evilmonkey19
Copy link
Author

ooohh I didn't add it in the celery worker. I didn't see that in the job's documentation. I will check it out on monday :)

@evilmonkey19
Copy link
Author

Hi! I'm sorry for the problem. Yes, it was simply the celery worker container problem :( .

Thanks a lot for the reply!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested triage This issue is new and has not been reviewed. type: bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants