Repository navigation
fix: gather_subsets for gtm server vs stats 404 if name has space - #2536
Conversation
Ref:AUTOTOOL-5391
crosbygw
left a comment
There was a problem hiding this comment.
Code Review Summary — AUTOTOOL-5391-spaced-vs-name vs devel
Change: In bigip_device_info.py, GtmServersParameters._read_virtual_stats_from_device now suppresses a 404 (returns {}) instead of raising F5ModuleError, when the request URI contains a whitespace/%20 and ends in /stats. Intent: avoid failures when a GTM server's virtual-server name has a space.
Issues found
- Moderate — regex is too broad (bigip_device_info.py:11017)
if (resp.status == 404 or response.get('code') == 404) and re.match(r'(.(\s|(%20))+.)/stats$', uri.rstrip()):
return {}
It matches whitespace/%20 anywhere in the URI, not just in the virtual-server name segment. So a 404 gets silently swallowed even when the space is in the partition/server name and the virtual server itself was genuinely deleted/renamed (e.g. .../gtm/server/My Partitionserver1/virtual-servers/vs1/stats). This masks legitimate "not found" errors, not just the specific space-encoding bug being targeted. Suggest scoping the match to just the path segment immediately before /stats. - Minor — silent data loss (bigip_device_info.py:11017-11018)
When suppressed, {} is returned with no warning, so downstream stats fields (status, state, bits_per_sec_in, etc.) are silently omitted for that virtual server. Codebase precedent (e.g. bigip_command.py:461) uses self.module.warn(...) in similar cases — worth adding here for visibility. - Minor nit — style inconsistency, not a bug. New check uses response.get('code') vs. the existing pattern above using 'code' in response and response['code']. Functionally fine, just inconsistent style.
- Test gap: New unit tests (test_bigip_device_info.py:303-411) cover space, encoded-space, non-space 404, 500 error, and success cases — but don't cover the false-positive scenario in issue #1 (space elsewhere in path, VS legitimately missing), which is the actual gap.
Bottom line
The fix works for the intended case but is broader than necessary, risking silently hidden genuine 404 errors when whitespace appears elsewhere in the URL path (e.g., partition names). Recommend narrowing the regex to only match the virtual-server name segment before merging.
3c72299 to
026b638
Compare
Ref:AUTOTOOL-5391
026b638 to
680569a
Compare
|
Summary
Fixes an issue in
bigip_device_infowhere gatheringgtm-serversfacts fails with a 404 error when a virtual server reference has spaces in its name. The module now gracefully handles missing virtual server statistics for spaced names instead of aborting fact collection.Changes
Module
ansible_collections/f5networks/f5_modules/plugins/modules/bigip_device_info.py: InGtmServersParameters._read_virtual_stats_from_device, ignore 404 responses when querying/statsfor virtual servers whose URI contains spaces or encoded spaces (%20), returning an empty dict for stats instead of raisingF5ModuleError.Tests
ansible_collections/f5networks/f5_modules/tests/unit/modules/network/f5/test_bigip_device_info.py: Added unit test cases covering 404 responses with spaces, 404 with%20, 404 without spaces (still raisingF5ModuleError), 500 error handling, and 200 success responses.Documentation
ansible_collections/f5networks/f5_modules/changelogs/fragments/fix-gtm-servers-virtual-server-spaces.yaml: Added changelog fragment documenting the bugfix.API Endpoints
/mgmt/tm/gtm/server/<server>/virtual-servers/<virtual_server>/statsTesting
test_bigip_device_info.pycovering all edge cases (spaced names,%20encoded names, standard names, error statuses).test_bigip_device_info.pypass.jdk_play.ymlplaybook against a live BIG-IP with spaced GTM virtual server objects.Checklist
Ref:AUTOTOOL-5392