Skip to content

Fixing cannot unmarshal into big.int large network_ip_availabilities_total metric#447

Merged
Sharpz7 merged 9 commits intoopenstack-exporter:mainfrom
fnzv:fix_large_available_ipv6
Nov 30, 2025
Merged

Fixing cannot unmarshal into big.int large network_ip_availabilities_total metric#447
Sharpz7 merged 9 commits intoopenstack-exporter:mainfrom
fnzv:fix_large_available_ipv6

Conversation

@fnzv
Copy link
Copy Markdown

@fnzv fnzv commented May 19, 2025

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:

ts=2025-05-19T11:59:33.865Z caller=exporter.go:112 level=info msg="Collecting metrics for exporter" exporter=openstack_neutron metrics=network_ip_availabilities_total
ts=2025-05-19T11:59:34.010Z caller=exporter.go:138 level=error err="Failed to collect metric for exporter" exporter=neutron error="failed to collect metric: network_ip_availabilities_total, error: math/big: cannot unmarshal \"xxxxxxxxxxxe+24\" into a *big.Int" 

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

@Sharpz7
Copy link
Copy Markdown
Collaborator

Sharpz7 commented Jul 3, 2025

Hey @fnzv

@mnaser and I are new maintainers of the repository and will aim to get reviews on all outstanding PR's ASAP.

Can you ensure that you are using GPG verified signatures and force new commits?

Thanks!

@fnzv fnzv force-pushed the fix_large_available_ipv6 branch from b6ff25b to bd27804 Compare July 3, 2025 05:37
@fnzv
Copy link
Copy Markdown
Author

fnzv commented Jul 3, 2025

Hey @Sharpz7 and @mnaser 👋

I just rebased and force pushed the verified commit

@Sharpz7 Sharpz7 added the priority Priority PR or Issue to help with tracking. label Jul 16, 2025
@Sharpz7
Copy link
Copy Markdown
Collaborator

Sharpz7 commented Sep 2, 2025

@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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Number fields to handle large IP counts
  • Bypasses gophercloud's built-in unmarshaling to avoid the big.Int error
  • 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.

Comment thread exporters/neutron.go
Comment thread exporters/neutron.go
@Sharpz7 Sharpz7 merged commit 7d63273 into openstack-exporter:main Nov 30, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority Priority PR or Issue to help with tracking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants