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

Interface-connections filter only searches lowest PK interface device #5627

Closed
ajmyyra opened this issue Jan 14, 2021 · 5 comments
Closed

Interface-connections filter only searches lowest PK interface device #5627

ajmyyra opened this issue Jan 14, 2021 · 5 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@ajmyyra
Copy link

ajmyyra commented Jan 14, 2021

Environment

  • Python version: 3.9.1
  • NetBox version: 2.10.3

Steps to Reproduce

API endpoint for listing interface connection seems to have broken between versions 2.9 and 2.10.

  1. Create two devices with a connection between their interfaces, starting from the first device.
  2. Try using hostname with /api/dcim/interface-connections/?device=HOSTNAME and get HTTP error 500
  3. Try listing interfaces for the second device with /api/dcim/interface-connections/?device_id=2 (or whatever id you have) and get an empty list.

Expected Behavior

You could previously fetch device's interface connections with /api/dcim/interface-connections/?device=HOSTNAME or with /api/dcim/interface-connections/?device_id=1337 . API should return all connections where the device is a part of, no matter the end of cable the device is in (so both interface_a and interface_b). This behaviour is still standard in the web interface where all connections are shown under /dcim/devices/1337/interfaces/ .

Observed Behavior

Using the interface-connections endpoint with ?device=HOSTNAME returns ValueError with a HTTP status of 500 and the error message of "Field 'id' expected a number but got 'server01'."

Looking at the commits for 2.10 (this for example), it seems like searching with a name has been deprecated and you can actually use both device or device_id to list the connections when you specify the id. This however works only for listing connections that have their first end (interface_a) as that device. As I expect to use the API endpoint (and can use the web interface) to see all connections to and from that device, I consider this a bug.

@DanSheps DanSheps added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application labels Jan 14, 2021
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Jan 19, 2021
@jeremystretch jeremystretch self-assigned this Jan 19, 2021
@jeremystretch
Copy link
Member

Try using hostname with /api/dcim/interface-connections/?device=HOSTNAME and get HTTP error 500

Looks like you've encountered two different issues. I've opened #5639 to address the error when filtering by device name.

@jeremystretch jeremystretch removed their assignment Jan 19, 2021
@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation and removed status: accepted This issue has been accepted for implementation labels Jan 19, 2021
@DanSheps DanSheps changed the title Interface-connections API endpoint gives only one-sided information or error 500 Interface-connections filter only searches lowest PK interface device Feb 12, 2021
@jeremystretch
Copy link
Member

These views are due to be removed under #5223 as they no longer serve much of a purpose (they predate cabling support). Not sure it's worth the effort pursuing this.

@kjellrg
Copy link

kjellrg commented Apr 28, 2021

We upgraded from v2.9.4 to v2.11.2 and are experiencing this issue as well. We are not getting an HTTP 500 error, but the response is an empty or incomplete list.

  • Both /api/dcim/interface-connections/?device=HOSTNAME and /api/dcim/interface-connections/?device_id=ID returns an empty list, unless the specified hostname/device_id is on the "interface_a" side of things.

We are not able to consistently specify what is in the "interface_a" of a link, so this will return an incomplete result in most cases.

The v2.11.2 instance is running a copy of the v2.9.4 database and manage.py migrate" has been run. In the UI we can see and trace all connections correctly in v2.11.2

v2.9.4:
In [35]: len(netbox.dcim.get_interface_connections(device="sw00027"))
Out[35]: 29

v2.11.2
In [36]: len(netboxdevel.dcim.get_interface_connections(device="sw00027"))
Out[36]: 0

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@github-actions github-actions bot added the pending closure Requires immediate attention to avoid being closed for inactivity label Jun 28, 2021
@jeremystretch jeremystretch added status: blocked Another issue or external requirement is preventing implementation and removed pending closure Requires immediate attention to avoid being closed for inactivity status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Jul 6, 2021
@jeremystretch jeremystretch added status: under review Further discussion is needed to determine this issue's scope and/or implementation and removed status: blocked Another issue or external requirement is preventing implementation labels Jul 8, 2021
@jeremystretch
Copy link
Member

Maybe we should just remove the duplicate filtering from the interface connections view. That will return all end-to-end connections (typically doubling the number currently returned), but will ensure that filtering is applied consistently.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Jul 27, 2021
@jeremystretch jeremystretch self-assigned this Jul 27, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2021
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

4 participants