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

More complex Dynamic Group Filters With Devices without platforms cause job failures for out of scope devices. #843

Open
jeffkala opened this issue Dec 5, 2024 · 1 comment

Comments

@jeffkala
Copy link
Contributor

jeffkala commented Dec 5, 2024

Environment

  • Python version: 3.11
  • Nautobot version: 2.3.12
  • nautobot-golden-config version: 2.2.1

devices_no_platform = devices_filtered.qs.filter(platform__isnull=True)

causes issues even when devices are not in the GC scope.

Expected Behavior

Any device platform checks should only occur against devices in scope for the setting.

Observed Behavior

A out of scope device not in the GC scope not having a platform set fails a GC job.

Screenshot 2024-12-05 at 2 56 08 PM

The get_job_filter helper function doesn't have a starting point of the dynamic group

Steps to Reproduce

  1. Follow standard GC prereqs.
  2. Create a GC scoped Dynamic Group that is a group of groups, and the child groups are filter-defined groups.
    Screenshot 2024-12-05 at 2 59 11 PM

For example this DG selected "all" sites, and then added a advanced filter that removed 1 of the sites. The dynamic group membership itself is correct! so its not an issue with the DG calculation.

  1. On one of the out of scope devices unset the platform.
  2. Run one of the GC jobs.

Traceback

worker-1    | [2024-12-05 21:40:42,996: ERROR/ForkPoolWorker-6] Task nautobot.extras.jobs.run_job[053255ed-6510-41db-9006-d45b74774e04] raised unexpected: NornirNautobotException('`E3017:` The following device(s) veos have no platform defined. Platform is required.')
worker-1    | Traceback (most recent call last):
worker-1    |   File "/usr/local/lib/python3.11/site-packages/celery/app/trace.py", line 477, in trace_task
worker-1    |     R = retval = fun(*args, **kwargs)
worker-1    |                  ^^^^^^^^^^^^^^^^^^^^
worker-1    |   File "/usr/local/lib/python3.11/site-packages/celery/app/trace.py", line 760, in __protected_call__
worker-1    |     return self.run(*args, **kwargs)
worker-1    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1    |   File "/usr/local/lib/python3.11/site-packages/nautobot/extras/jobs.py", line 1136, in run_job
worker-1    |     result = job(*args, **kwargs)
worker-1    |              ^^^^^^^^^^^^^^^^^^^^
worker-1    |   File "/usr/local/lib/python3.11/site-packages/nautobot/extras/jobs.py", line 149, in __call__
worker-1    |     return self.run(*args, **deserialized_kwargs)
worker-1    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1    |   File "/source/nautobot_golden_config/jobs.py", line 170, in gc_repo_wrapper
worker-1    |     current_repos = gc_repo_prep(job=self, data=kwargs)
worker-1    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1    |   File "/source/nautobot_golden_config/jobs.py", line 120, in gc_repo_prep
worker-1    |     job.qs = get_job_filter(data)
worker-1    |              ^^^^^^^^^^^^^^^^^^^^
worker-1    |   File "/source/nautobot_golden_config/utilities/helper.py", line 92, in get_job_filter
worker-1    |     raise NornirNautobotException(
worker-1    | nornir_nautobot.exceptions.NornirNautobotException: `E3017:` The following device(s) veos have no platform defined. Platform is required.
@jeffkala
Copy link
Contributor Author

jeffkala commented Dec 5, 2024

Ultimately looks as if the complex DG filters are not actually getting populated in the GC settings therefore

Screenshot 2024-12-05 at 3 06 36 PM

if not models.GoldenConfigSetting.objects.filter(dynamic_group__filter__iexact="{}").exists()

Is essentially a inaccurate test. Commenting it out and de-intending the next for loop is a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants