netbox-community / netbox-docker

🐳 Docker Image of NetBox
https://github.com/netbox-community/netbox-docker/wiki
Apache License 2.0
1.73k stars 800 forks source link

Git datasource sync error in rq-worker: LookupError: App 'core' doesn't have a 'ObjectType' model. #1241

Closed haki99 closed 1 month ago

haki99 commented 1 month ago

Current Behavior

Hi everyone!

After upgrading from v3.7.4 to v4.0.2 Netbox version I tried to add a git repository as a data source, it is successfully created it, but when I tried to sync it the job never finished and it is stuck in queued status. On version v3.7.4 it is still working as expected.

(The logs are from the worker.)

I didn't found any related issue to this and I tried the following steps:

Expected Behavior

Successful sync of a git data source.

Docker Compose Version

v2.9.1

Docker Version

docker:20.10.10

The git Revision

6d25a54d4909edfb4e97356b6097848592039c3c

The git Status

On branch release
Your branch is up to date with 'origin/release'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   configuration/plugins.py
        modified:   env/netbox.env

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Dockerfile-Plugins
        plugin_requirements.txt
        ssl/

no changes added to commit (use "git add" and/or "git commit -a")

Startup Command

docker compose up

NetBox Logs

(The logs are from the worker.)

11:23:53 [Job 6ee2b617-4ff8-4fa9-95d4-479e233a3ec7]: exception raised while executing (<DeserializationError>)
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/apps/config.py", line 235, in get_model
    return self.models[model_name.lower()]
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
KeyError: 'objecttype'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.11/site-packages/rq/job.py", line 486, in _deserialize_data
    self._func_name, self._instance, self._args, self._kwargs = self.serializer.loads(self.data)
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/models/base.py", line 2524, in model_unpickle
    model = apps.get_model(*model_id)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/apps/registry.py", line 213, in get_model
    return app_config.get_model(model_name, require_ready=require_ready)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/apps/config.py", line 237, in get_model
    raise LookupError(
LookupError: App 'core' doesn't have a 'ObjectType' model.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.11/site-packages/rq/worker.py", line 1424, in perform_job
    self.prepare_job_execution(job, remove_from_intermediate_queue)
  File "/opt/netbox/venv/lib/python3.11/site-packages/rq/worker.py", line 1353, in prepare_job_execution
    self.procline(msg.format(job.func_name, job.origin, time.time()))
                             ^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.11/site-packages/rq/job.py", line 520, in func_name
    self._deserialize_data()
  File "/opt/netbox/venv/lib/python3.11/site-packages/rq/job.py", line 488, in _deserialize_data
    raise DeserializationError() from e
rq.exceptions.DeserializationError

Content of docker-compose.override.yml

version: '3.4'
services:
  netbox:
    ports:
      - "8000:8080"
tobiasge commented 1 month ago

The error LookupError: App 'core' doesn't have a 'ObjectType' model. is strange because ObjectType is model that is present in NetBox directly. Thats not an addition from the Docker image. Are you sure, that the netbox-worker container is running the same image version as the netbox container?

haki99 commented 1 month ago

Thanks @tobiasge, that was the issue! I close as resolved and keep it for the future as a note to always check it. :)