fix: Avoid paging in ListHypervisors#520
fix: Avoid paging in ListHypervisors#520dsanader wants to merge 1 commit intoopenstack-exporter:mainfrom
Conversation
|
Well, it happens to be more complicated than I thought. My initial "fix" was in fact ugly. It actually uses an Regarding #505, it does indeed automatically sets the latest supported Microversion, but since @@ -167,8 +167,17 @@ func ListNovaAgentState(ctx context.Context, exporter *BaseOpenStackExporter, ch
func ListHypervisors(ctx context.Context, exporter *BaseOpenStackExporter, ch chan<- prometheus.Metric) error {
var allHypervisors []hypervisors.Hypervisor
var allAggregates []aggregates.Aggregate
+ var listOpts hypervisors.ListOpts
- allPagesHypervisors, err := hypervisors.List(exporter.ClientV2, nil).AllPages(ctx)
+ apiMv, _ := strconv.ParseFloat(exporter.ClientV2.Microversion, 64)
+ if apiMv >= 2.33 {
+ limit := 1000
+ listOpts = hypervisors.ListOpts{Limit: &limit}
+ } else {
+ listOpts = hypervisors.ListOpts{}
+ }
+
+ allPagesHypervisors, err := hypervisors.List(exporter.ClientV2, listOpts).AllPages(ctx)
if err != nil {
return err
}Lastly, on older versions of Nova, the The python SDK includes a fallback logic which covers that (see: https://opendev.org/openstack/openstacksdk/src/commit/fb794edea9c1d1e9e4da8397f0dc9adc73bd1de1/openstack/resource.py#L2213). So, that behavior can't be seen with the |
bcb575d to
c7efd41
Compare
c7efd41 to
e9c9fb6
Compare
|
I've changed my code to explicitly set a microversion not supporting pagination for the hypervisors list call for the time being. Since having >1000 compute nodes is not that common, I guess it can wait a more proper fix when the gophercloud v2 is merged. |
|
Appreciate the detailed breakdown @dsanader . Thank you! |
Fix openstack-exporter#519 which is proposed in openstack-exporter#520 Co-authored-by: Dejan Sanader <dejan.sanader@ovhcloud.com> Signed-off-by: Vladimir Ermakov <vooon341@gmail.com>
|
@dsanader i've added your fix to v2. |
Fix openstack-exporter#519 which is proposed in openstack-exporter#520 Co-authored-by: Dejan Sanader <dejan.sanader@ovhcloud.com> Signed-off-by: Vladimir Ermakov <vooon341@gmail.com>
Fix openstack-exporter#519 which is proposed in openstack-exporter#520 Co-authored-by: Dejan Sanader <dejan.sanader@ovhcloud.com> Signed-off-by: Vladimir Ermakov <vooon341@gmail.com>
Fix openstack-exporter#519 which is proposed in openstack-exporter#520 Co-authored-by: Dejan Sanader <dejan.sanader@ovhcloud.com> Signed-off-by: Vladimir Ermakov <vooon341@gmail.com>
Fix openstack-exporter#519 which is proposed in openstack-exporter#520 Co-authored-by: Dejan Sanader <dejan.sanader@ovhcloud.com> Signed-off-by: Vladimir Ermakov <vooon341@gmail.com>
Proposal to fix #519