Skip to content

vmware: fetch each vCenter tag and category once per run - #621

Open
tyderian1978 wants to merge 1 commit into
bb-Ricardo:developmentfrom
tyderian1978:perf/vmware-tag-cache
Open

tyderian1978 wants to merge 1 commit into
bb-Ricardo:developmentfrom
tyderian1978:perf/vmware-tag-cache

Conversation

@tyderian1978

Copy link
Copy Markdown

Disclaimer: AI generated, based off the work we're doing with Netbox.

What happens

get_vmware_object_tags() asks the vSphere tagging API for every tag attached to an object, and for the tag's category when tag_name_include_category is set, for every cluster, host and VM. Most objects share a small set of tags, so a run fetches the same tags thousands of times, one HTTPS request each. On the two vCenters we measured, that was about 21,000 tag and category lookups per run, for about 700 distinct ones.

Fix

Tags and category names are kept by id for the run, per source (tag ids are only unique within one vCenter). The tags returned are unchanged. The caches are created on first use rather than in __init__, so a handler built without __init__, as tests/test_vmware_tag_category.py does, works too.

Tests

tests/test_vmware_tag_cache.py, with a fake tagging API that counts lookups: five objects sharing two tags cost two tag lookups (and two category lookups with tag_name_include_category) and get the same tags as before; two sources keep separate caches. The lookup counts fail on development without the change. Full suite: 610 passed, 8 skipped.

Together with the IP address index (separate PR), a dry run against our production NetBox and vCenters went from 38 min 45 s to 27 min 42 s, with identical planned changes.

get_vmware_object_tags() fetched every tag attached to an object, and its
category when tag_name_include_category is set, from the vSphere tagging
API, for every object. Most objects share a few hundred tags, so a run
fetched the same tags thousands of times, one HTTPS request each.

Tags and category names are now kept by id for the run, per source (tag
ids are only unique within one vCenter). The tags returned are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant