Skip to content

Job hanging / Event Rule for virtual machine model launching custom script causes job to hang #19204

@chaeynz

Description

@chaeynz

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)

  1. Add custom script to Netbox that returns data
  2. Create Event Rule for Virtual Machine with Action: Launch Script
  3. Create/modify virtual machine

Script:

from extras.scripts import *
class MyCustomScript(Script):

    class Meta:
        name = "My Custom Script"
        description = "My description"


    def run(self, data, commit):

        return data

Virtual Machine Custom Fields:
2x Selection
1x Multiple Selection
1x Object:
Image

Platform Custom Fields:
1x Selection

Tenant Custom Fields:
1x Object: Netbox-DNS->Record

Here a quick json dump of the virtual machine I created.

{
    "id": 153,
    "url": "https://mydomain/api/virtualization/virtual-machines/153/",
    "display_url": "mydomain/virtualization/virtual-machines/153/",
    "display": "test",
    "name": "test",
    "status": {
        "value": "active",
        "label": "Active"
    },
    "site": {
        "id": 2,
        "url": "https://mydomain/api/dcim/sites/2/",
        "display": "NEXS_00",
        "name": "NEXS_00",
        "slug": "nexs_00",
        "description": "Chaeynz Home"
    },
    "cluster": {
        "id": 1,
        "url": "https://mydomain/api/virtualization/clusters/1/",
        "display": "RC",
        "name": "RC",
        "description": ""
    },
    "device": null,
    "serial": "",
    "role": null,
    "tenant": null,
    "platform": null,
    "primary_ip": null,
    "primary_ip4": null,
    "primary_ip6": null,
    "vcpus": null,
    "memory": null,
    "disk": null,
    "description": "",
    "comments": "",
    "config_template": null,
    "local_context_data": null,
    "tags": [],
    "custom_fields": {
        "resource_pool": null,
        "machine_service_category": null,
        "nfs_share": null,
        "vm_prefix": null
    },
    "config_context": {},
    "created": "2025-04-15T20:24:08.790042Z",
    "last_updated": "2025-04-15T20:42:32.559175Z",
    "interface_count": 0,
    "virtual_disk_count": 0
}

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.

Image

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtopic: event rulesFor issues related to the Event Rules featuretype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions