-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Inconsistent /api/virtualization/interfaces/ results #2207
Comments
Thank you for taking the time to report a bug. We'll need more information to investigate this issue. Per the contributing guidelines please ensure that you have included all of the following:
Please update your issue to include all of the information listed above. If no response is received within a week, this issue will be closed. Thanks! |
import pynetbox
for vif in nb.virtualization.interfaces.all():
print(vif.id) Duplicate ids are printed. I guess it requires you to have enough interfaces to get this bug triggered consistently. I've "fixed" it by changing the ordering in the Interface model ( |
Still can't reproduce this. The queryset which retrieves the interfaces is:
Not sure how that could result in duplicate objects being returned. I'll need sample data which triggers the bug to dig any further into this. |
Can I send you a dump of my database by email ? |
Sorry, you'll need to derive a sample set from your data which can be used to replicate the problem and post it here. |
Closing due to lack of activity. |
Hello Jeremy, Finally got some time to work on this. The key is to a have a mixed set of device and vm interfaces and to have a count above the paging size (>1000). On a fresh 2.5.6 install with the initial data and after loading some dummy devices and vms with the attached script, you should witness the inconsistency : vifs = [iface.id for iface in nb.virtualization.interfaces.all()]
len(vifs)
600
len(set(vifs))
567 |
@dsanader Unless you can recreate this using bare HTTP calls NetBox REST API, you'll need to open this as a bug against the pynetbox library. |
You're hard on me... Anyway, same outcome with curl :
The issues goes away (600 unique ids) as soon as I : index 3b0c02b2..f9502071 100644
--- a/netbox/virtualization/api/views.py
+++ b/netbox/virtualization/api/views.py
@@ -65,7 +65,7 @@ class VirtualMachineViewSet(CustomFieldModelViewSet):
class InterfaceViewSet(ModelViewSet):
queryset = Interface.objects.filter(
virtual_machine__isnull=False
- ).select_related('virtual_machine').prefetch_related('tags')
+ ).select_related('virtual_machine').prefetch_related('tags').order_by('id')
serializer_class = serializers.InterfaceSerializer
filterset_class = filters.InterfaceFilter |
* Added 'id' field sort to InterfaceManager
This is almost identical to #2938, which was fixed in v2.5.8, except that the Interface model uses its own manager. |
Tested PR 2996 on my NetBox v 2.5.8 instance: 69 sql_col = '{}.name'.format(self.model._meta.db_table)
70 ordering = [
71 '_slot', '_subslot', '_position', '_subposition', '_type', '_id', '_channel', '_vc', 'name', 'pk'
72 ]
73 Still the same issue with interfaces not being returned as a unique list. |
Tested on a full 2.5.9, and that works. Probably something I messed up with my test or some such. Huzzah! |
Issue type
[ ] Feature request
[ x ] Bug report
[ ] Documentation
Environment
Description
Querying all virtualized interfaces returns inconsistents results : the count is OK, but some interfaces are missing and some are duplicated.
The underlying query is ordering by an empty column ("dcim_device"."name") which seems to fall under the non predictable results case : https://www.postgresql.org/docs/current/static/queries-limit.html
The text was updated successfully, but these errors were encountered: