nautobot-app-device-lifecycle-mgmt icon indicating copy to clipboard operation
nautobot-app-device-lifecycle-mgmt copied to clipboard

Device Software Validation Job Needs Refactor

Open jdrew82 opened this issue 3 months ago • 4 comments

Environment

  • Python version: 3.10
  • Nautobot version: 2.1.5
  • nautobot-device-lifecycle-mgmt version: 2.1.0

Expected Behavior

Only Devices that have a Software object associated to it will be evaluated against the Validated Software in the Device Software Validation Job.

Observed Behavior

All Devices, whether they have Software associated or not, will be evaluated. This isn't that big of a deal with a small number of Devices but as the number gets larger it increases the time for the Job to be completed.

Steps to Reproduce

  1. Create Devices without Software associated.
  2. Run Device Software Validation Job.
  3. See length of time to complete scales as you add Devices.

jdrew82 avatar Mar 07 '24 17:03 jdrew82

This is by design. We have "Exclude missing software" and "Show only missing software" filters on the report page which rely on the validation records having been created for all devices/invitems, see demo https://demo.nautobot.com/plugins/nautobot-device-lifecycle-mgmt/validated-software-device-report/ .

We could potentially add an option to the job to only run validation for devices/invitems that have software. We'd first need to assess how will that affect logic on the reporting side.

progala avatar Mar 07 '24 18:03 progala

That's not the problem I'm talking about. I'm specifically talking about the actual tests. They're just taking in all Device and InventoryItem objects regardless of whether they actually have a RelationshipAssociation or not. This means that if a user has 10k devices and only 10 of them have a Software associated it'll still try to process 10k objects instead of the 10 it should making the tests take far longer than they should. We're seeing this in a client where they have almost 69k devices and about 1k don't have any Software associated and the test is timing out with our 3 hour timeout.

jdrew82 avatar Mar 07 '24 19:03 jdrew82

I get what you're saying about wanting to have it in the report about Devices or InventoryItems missing Software but there's gotta be a better way of determining that.

jdrew82 avatar Mar 07 '24 19:03 jdrew82

We should be able to optimize the validation job by processing objects without Software separately. We know these will fail validation so we can simply create/refresh ValidationResult objects without having to call the full validation logic. What I don't want to do is to introduce a change breaking the existing default behavior, i.e. ValidationResult records being produced for objects without Software.

progala avatar Mar 08 '24 11:03 progala