Repository navigation
vmware: keep syncing when a vCenter tag lookup fails - #637
Open
tyderian1978 wants to merge 1 commit into
Open
tyderian1978 wants to merge 1 commit into
tyderian1978 wants to merge 1 commit into
Conversation
get_vmware_object_tags() returned None when listing the tags attached to an object failed, and for no object at all. collect_object_tags() extends its tag list with every result, so a single failed tag request ended the whole run with "TypeError: 'NoneType' object is not iterable", right after logging "Unable to retrieve vCenter tags for ...". Both functions now always return a list. The object only loses the tags of the lookup which failed: its other tag sources (parent folders, cluster, datacenter) still count and the sync goes on. The error is logged as before.
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.
Disclaimer: AI generated, based off the work we're doing with Netbox.
What happens
When the vSphere tagging API fails to list the tags attached to an object, for example after a vCenter error or a timeout,
get_vmware_object_tags()logsUnable to retrieve vCenter tags for '<object>'and returnsNone.collect_object_tags()extends its tag list with that result, so the sync stops withTypeError: 'NoneType' object is not iterable. A single failed tag request ends the whole run. Both functions also returnNonewhen they're given no object.We ran into it while testing #634–#636 against vcsim, whose tagging API doesn't work with the
vcf-sdk, so every tag lookup there fails.Fix
Both functions always return a list. The object only loses the tags of the lookup that failed: its other tag sources (parent folders, cluster, datacenter) still count, and the sync goes on. The error is logged as before.
Tests
tests/test_vmware_tag_errors.pyfakes the tagging API:Both fail on
development, the first with theTypeErrorabove. Full suite: 836 passed, 8 skipped.This PR changes lines that #634 also changes: the
tryaroundlist_attached_tags()inget_vmware_object_tags(). Whichever is merged second, I'll rebase it.