fix: stops orphan tagging redfish inventory items the source still manages - #545
Open
marcinpsk wants to merge 1 commit into
Open
fix: stops orphan tagging redfish inventory items the source still manages#545marcinpsk wants to merge 1 commit into
marcinpsk wants to merge 1 commit into
Conversation
…anages tag_all_the_things() adds the orphaned tag to every object which carries the primary tag and which a run does not register with its source. Two paths left inventory items untouched, so they were tagged orphaned while the source was still managing them. update_all_items() read the component type back from the first item in the batch and returned early on an empty list. A scan which reports no component of a type therefore left every one of that device's components of that type untouched, instead of marking them absent. A server whose fans stop being reported is the case which shows it. The type is now passed in by the caller, which knows it whether or not the batch is empty, and is stamped onto the items, so the value used for the lookup and the value stored on each item cannot drift apart. Marking an item absent was also conditional on its health actually changing, so an item already at absent was never touched again on any later run and was tagged orphaned from then on. Registering the item with the source is now unconditional. update() still writes nothing when the value is unchanged, so this adds no NetBox requests. The tests seed items the way query_current_data() does, then drive the real update_fan() and the real tag_all_the_things(). Both fail before this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
tag_all_the_things()adds the orphaned tag to every object which carries the primary tag and which a run does not register with its source. Two paths in the check_redfish source left inventory items untouched, so they were tagged orphaned while the source was still managing them.1. An empty batch said nothing.
update_all_items()read the component type back from the first item in the batch and returned early on an empty list:A scan which reports no component of a type therefore left every one of that device's components of that type untouched, instead of marking them absent. A server whose fans stop being reported is the case which shows it.
2. Already absent items were never touched again. Marking an item absent was conditional on its health actually changing:
So an item already at absent was skipped on every later run, and tagged orphaned from then on.
Fix
The component type is passed in by the caller, which knows it whether or not the batch is empty, and is stamped onto the items in
update_all_items(), so the value used for the lookup and the value stored on each item cannot drift apart.Registering the item with the source is now unconditional.
update()still writes nothing when the value is unchanged, so this adds no NetBox requests.Notes
update_all_items()signature and drops the per-iteminventory_typekey at the nine call sites.[tool.pytest.ini_options]topyproject.tomlmake_source()helper - should be moved totests/conftest.pywhen available (I see it in adds a vcsim based test suite and runs it in CI #541)