-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Job hanging / Event Rule for virtual machine model launching custom script causes job to hang #19204
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
Comments
note
|
Weird, it does seem to only do it for Virtual Machines, get's following stack trace:
|
This is reproducible for other objects as well (sites, for instance). This is happening because the data passed to the script's Here's a reproduction which isolates the root issue from the custom script & event rule: >>> import json
>>> from virtualization.api.serializers import VirtualMachineSerializer
>>>
>>> vm = VirtualMachine.objects.first()
>>> data = VirtualMachineSerializer(vm, context={'request': None}).data
>>> json.dumps(data)
Traceback (most recent call last):
File "/usr/lib/python3.10/code.py", line 90, in runcode
exec(code, self.locals)
File "<console>", line 1, in <module>
File "/usr/lib/python3.10/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.10/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.10/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.10/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type __proxy__ is not JSON serializable
>>> type(data['status']['label'])
<class 'django.utils.functional.lazy.<locals>.__proxy__'> In practice, the exception is raised because NetBox is trying to save the output returned by |
I should note for posterity that the fix for this bug is limited to the specific scenario detailed above. The switch to using DjangoJSONEncoder will not magically serialize arbitrary objects, but it does provide better serialization support in general. |
Why was it hanging though, shouldnt the job returned the TypeError error? |
Uh oh!
There was an error while loading. Please reload this page.
Deployment Type
Self-hosted
NetBox Version
4.2.6
Python Version
3.11
Steps to Reproduce
Redis server v=7.0.15 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=c89c70d1d28059e4
(probably not relevant, but here u go)
Script:
Virtual Machine Custom Fields:

2x Selection
1x Multiple Selection
1x Object:
Platform Custom Fields:
1x Selection
Tenant Custom Fields:
1x Object: Netbox-DNS->Record
Here a quick json dump of the virtual machine I created.
I did not investigate further, but it seems to me there is some kind of loop going on. You have try except blocks in the code to launch scripts from what I am seeing..
Maybe it is because of the relation with objects?
I hope this is useful, if you have any questions I will be happy to help!
Expected Behavior
Script should return virtual machine json data
Or.. atleast timeout?
Observed Behavior
After 1 hour the jobs are still hanging that ran against for my virtual machine model.
The text was updated successfully, but these errors were encountered: