Fixing cannot unmarshal into big.int large network_ip_availabilities_total metric#447
Conversation
b6ff25b to
bd27804
Compare
|
@fnzv I would appreciate reviews on the other priority-labelled tickets if you have the time so I can get them merged too :). I am personally still working on integration tests to increase confidence in merges. I have asked others to do the same on this PR. |
…ix_large_available_ipv6 Signed-off-by: Sharpz7 <adam.mcarthur62@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical unmarshaling error in the Neutron exporter that occurs when handling large IPv6 network IP availability counts. The issue arose because gophercloud's default unmarshaling attempted to parse large numbers (e.g., 1.8446744073709552e+19) into big.Int, which cannot handle scientific notation. The fix introduces custom JSON unmarshaling using json.Number to preserve the numeric string representation and then converts to float64 for Prometheus metrics.
Key changes:
- Implements custom struct definitions with
json.Numberfields to handle large IP counts - Bypasses gophercloud's built-in unmarshaling to avoid the
big.Interror - Adds proper JSON round-trip processing to decode network IP availability data
- Includes minor formatting fixes for consistency with Go style guidelines
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Hi there!
We encountered an issue releated to the openstack-exporter where a large number of IPv6 private and public networks can generate the following error:
In order to fix that we used a float64 thus being able to contain the large number provided by Openstack APIs
Hoping this could help also other people having the same issue