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

Dynamic Groups defined in <2.0 break in >2.0 #4612

Closed
JimmyKip opened this issue Oct 5, 2023 · 4 comments · Fixed by #4653
Closed

Dynamic Groups defined in <2.0 break in >2.0 #4612

JimmyKip opened this issue Oct 5, 2023 · 4 comments · Fixed by #4653
Assignees
Labels
type: bug Something isn't working as expected

Comments

@JimmyKip
Copy link

JimmyKip commented Oct 5, 2023

Environment

  • Nautobot version (Docker tag too if applicable): 1.6.x ->2.0.1
  • Python version: 3.11
  • Database platform, version: psql
  • Middleware(s): n/a

Steps to Reproduce

  1. In Nautobot 1.6.x create Dynamic Group using Tag tenant & status as a filter.
  2. Upgrade Nautobot to 2.0.1
  3. Attempt to open the dynamic group in the GUI

Expected the dynamic groups defined in 1.6.x to migrate safely to 2.0.1 and be able to open, view & edit the pre-upgrade dynamic group.

#4515 has restored tags to be used for filtering, and can successfully be applied to new dynamic groups, but so far all of the groups already setup cause log & display errors.

eg:

(
  tags__slug='campus' AND status__slug='active' AND tenant__slug='<tenant>'
)

Logs show warnings when NB2 launches:

07:33:41.815 WARNING nautobot.extras.models.groups :
  Filter for DynamicGroup "<tenant> Campus" is not valid

When attempting to open the dynamic group in GUI receive a Server Error:

<class 'KeyError'>

'tag'

Python version: 3.11.6
Nautobot version: 2.0.1
@JimmyKip JimmyKip added triage This issue is new and has not been reviewed. type: bug Something isn't working as expected labels Oct 5, 2023
@bryanculver bryanculver removed the triage This issue is new and has not been reviewed. label Oct 10, 2023
@HanlinMiao HanlinMiao self-assigned this Oct 12, 2023
@HanlinMiao
Copy link
Contributor

HanlinMiao commented Oct 12, 2023

Hi @JimmyKip, thank you for submitting this issue!
Are you able to identify what model content_type is the dynamic group associated with? And do you perhaps have a tag filter exist on this model filter set?

Also if you can provide some info on what the DynamicGorup looks like in 1.6 (in addition to the filter query provided above), it will be super helpful as well.

@JimmyKip
Copy link
Author

JimmyKip commented Oct 12, 2023

Hi,

They are associated with dcim.device; and yes they're using tag filters. I can make new groups ok now, but I can't view or edit the existing ones.

They're relatively simple filters so I could go through and recreate them all if needed, but it'll be a hassle for anyone using tags in dynamic groups with a large number of groups.

( tags__slug='all' AND status__slug='active' AND tenant__slug='<tenant>' )

@HanlinMiao
Copy link
Contributor

Thank you so much for the prompt response.

Can you go to nbshell and run this for loop to see if it fixes the issue? I can reproduce the KeyError when there is an outdated tag filter in my DynamicGroup filter data. This for loop goes through all the DPs and replace tag with tags.

for dp in DynamicGroup.objects.all():
    if "tag" in dp.filter:
        dp.filter["tags"] = dp.filter.pop("tag")
        dp.save()

@JimmyKip
Copy link
Author

Yep, that's perfect - they now load as expected.

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
No open projects
Status: Done
3 participants