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

[UI] VMs and devices in cluster from cluster type view is aways 0 #1459

Closed
jakubkrysl opened this issue Mar 8, 2022 · 4 comments · Fixed by #1477
Closed

[UI] VMs and devices in cluster from cluster type view is aways 0 #1459

jakubkrysl opened this issue Mar 8, 2022 · 4 comments · Fixed by #1477
Labels
type: bug Something isn't working as expected

Comments

@jakubkrysl
Copy link

Environment

  • Python version: 3.6.15
  • Nautobot version: v1.2.7

Looking at VM and device count from cluster type view always shows 0:
image
image
Show here on demo instance:
https://demo.nautobot.com/virtualization/cluster-types/test-cluster-type/

Steps to Reproduce

  1. Create cluster type
  2. Create cluster
  3. Create VM
  4. Open created cluster type
  5. look at number of VMs in the created cluster from this view
  6. look at number of devices in the created cluster from this view

Expected Behavior

1 (number of VMs in cluster)
1 (number of devices in cluster)

Observed Behavior

0 (always)
0 (always)

@glennmatthews glennmatthews added type: bug Something isn't working as expected workflow: under review labels Mar 8, 2022
@glennmatthews
Copy link
Contributor

Thanks for the report! It looks like a fix similar to netbox-community/netbox@98ff00b should resolve this.

@ubajze
Copy link
Contributor

ubajze commented Mar 10, 2022

@glennmatthews I was looking at this and I think the problem is elsewhere. We are already using the annotate function. I can easily reproduce this on other pages.

Here is an example:
Screenshot 2022-03-10 at 14 51 47
Screenshot 2022-03-10 at 14 51 59

It looks like a caching problem because, after some time, the number is refreshed.

My initial thought was that the problem is because the queryset variable is saved in the class object.

class DeviceRoleListView(generic.ObjectListView):
    queryset = DeviceRole.objects.annotate(
        device_count=count_related(Device, "device_role"),
        vm_count=count_related(VirtualMachine, "role"),
    )

@glennmatthews
Copy link
Contributor

@ubajze That seems like a separate issue to me. ClusterTypeView is not using annotations, unless I'm really missing something - https://github.com/nautobot/nautobot/blob/develop/nautobot/virtualization/views.py#L31 - and adding those annotations would be a necessary first step, regardless of caching issues.

@ubajze
Copy link
Contributor

ubajze commented Mar 10, 2022

@glennmatthews Ohh, you are right. I am sorry. The first image looks similar to that page:
https://demo.nautobot.com/virtualization/clusters/

So, my previous message should be ignored in the context of this issue.

I can open a PR tomorrow with the solution related to this issue.

@ubajze ubajze mentioned this issue Mar 11, 2022
glennmatthews added a commit that referenced this issue Mar 14, 2022
* Fix the issue 1459

* Try to make Black happy

* Apply suggestions from code review

Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants