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

Exception when modifying properties of an IP assigned to a VM #5035

Closed
abrahamvegh opened this issue Aug 23, 2020 · 3 comments
Closed

Exception when modifying properties of an IP assigned to a VM #5035

abrahamvegh opened this issue Aug 23, 2020 · 3 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@abrahamvegh
Copy link
Contributor

abrahamvegh commented Aug 23, 2020

Environment

  • Python version: 3.7.3
  • NetBox version: 2.9.1

Steps to Reproduce

  1. Create new IP e.g. 198.51.100.1/24
  2. Create new VM
  3. Create interface on VM
  4. Edit IP and assign as primary to the VM interface
  5. After the IP is assigned as primary, edit the IP and change the status to any other status
  6. Exception

Expected Behavior

Modifications to the IP should be accepted.

Observed Behavior

Exception:

Traceback (most recent call last):
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
   response = get_response(request)
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response
   response = wrapped_callback(request, *callback_args, **callback_kwargs)
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 73, in view
   return self.dispatch(request, *args, **kwargs)
 File "/opt/netbox/netbox/utilities/views.py", line 392, in dispatch
   return super().dispatch(request, *args, **kwargs)
 File "/opt/netbox/netbox/utilities/views.py", line 123, in dispatch
   return super().dispatch(request, *args, **kwargs)
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 101, in dispatch
   return handler(request, *args, **kwargs)
 File "/opt/netbox/netbox/utilities/views.py", line 418, in post
   if form.is_valid():
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 177, in is_valid
   return self.is_bound and not self.errors
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 172, in errors
   self.full_clean()
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 376, in full_clean
   self._post_clean()
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/models.py", line 405, in _post_clean
   self.instance.full_clean(exclude=exclude, validate_unique=False)
 File "/opt/netbox/venv/lib/python3.7/site-packages/django/db/models/base.py", line 1213, in full_clean
   self.clean()
 File "/opt/netbox/netbox/ipam/models.py", line 748, in clean
   elif self.interface.virtual_machine != vm:

Exception Type: AttributeError at /ipam/ip-addresses/4195/edit/
Exception Value: 'RelatedManager' object has no attribute 'virtual_machine'

This is presumably related to #4721. I bumped into it trying to update IPs relating to #4540.

@abrahamvegh abrahamvegh changed the title Exception when changing the status of an IP Exception when modifying properties of an IP assigned to a VM Aug 24, 2020
@abrahamvegh
Copy link
Contributor Author

This seems to be affecting any modification of an IP address assigned to a VM interface.

@jeremystretch
Copy link
Member

Please detail the exact steps someone else can take to replicate this bug, beginning with the creation of the IP address.

@jeremystretch jeremystretch added status: revisions needed This issue requires additional information to be actionable type: bug A confirmed report of unexpected behavior in the application labels Aug 24, 2020
@abrahamvegh
Copy link
Contributor Author

abrahamvegh commented Aug 24, 2020

Updated with full steps to reproduce. The hot path seems to be when an IP is marked as primary for the interface.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: revisions needed This issue requires additional information to be actionable labels Aug 24, 2020
@jeremystretch jeremystretch self-assigned this Aug 24, 2020
delkyd pushed a commit to delkyd/netbox that referenced this issue Sep 25, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants