benj-n opened a new issue, #8024:
URL: https://github.com/apache/cloudstack/issues/8024
<!--
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release and main branch are affected too.
Always add information AFTER of these HTML comments, but no need to delete
the comments.
-->
##### ISSUE TYPE
<!-- Pick one below and delete the rest -->
* Bug Report
##### COMPONENT NAME
<!--
Categorize the issue, e.g. API, VR, VPN, UI, etc.
-->
~~~
Prometheus Exporter
~~~
##### CLOUDSTACK VERSION
<!--
New line separated list of affected versions, commit ID for issues on main
branch.
-->
~~~
4.18
~~~
##### CONFIGURATION
<!--
Information about the configuration if relevant, e.g. basic network,
advanced networking, etc. N/A otherwise
-->
##### OS / ENVIRONMENT
<!--
Information about the environment if relevant, N/A otherwise
-->
##### SUMMARY
<!-- Explain the problem/feature briefly -->
When a host is set to be in 'maintenance', the corresponding capacity
entries are deleted from the `op_host_capacity` table.
In that case, the getCapacityState() (used here [1], for example) triggers a
NullPointer exception.
When it happens and the prometheus exporter fails, none of the data is
exposed to the prometheus collector.
[1]
https://github.com/apache/cloudstack/blob/f70b42a018d36dc2a63fee3ca93a64c578701d33/plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java#L166
##### STEPS TO REPRODUCE
<!--
For bugs, show exactly how to reproduce the problem, using a minimal
test-case. Use Screenshots if accurate.
For new features, show how the feature would be used.
-->
<!-- Paste example playbooks or commands between quotes below -->
~~~
1. On a 4.18+ setup, activate the prometheus exporter.
2. Set an external prometheus instance to collect from the exporter.
3. Set one (at least) cloudstack host in maintenance.
3. In the management server log, see the prometheus exporter triggers
Nullpointer exception. Observe the missing data in the prometheus instance.
~~~
<!-- You can also paste gist.github.com links for larger files -->
##### EXPECTED RESULTS
<!-- What did you expect to happen when running the steps above? -->
~~~
"Disabled" hosts or "in maintenance" should return metrics with a 0 value
and not block the procesing of all the data.
~~~
##### ACTUAL RESULTS
<!-- What actually happened? -->
<!-- Paste verbatim command output between quotes below -->
~~~
As soon as a host is in maintenance, the following nullpointer excpetion is
raised:
2023-09-28 12:18:47,258 WARN [o.a.c.m.PrometheusExporterImpl]
(HTTP-Dispatcher:null) (logid:) Getting metrics failed
java.lang.NullPointerException
at
org.apache.cloudstack.metrics.PrometheusExporterImpl.addHostMetrics(PrometheusExporterImpl.java:175)
at
org.apache.cloudstack.metrics.PrometheusExporterImpl.updateMetrics(PrometheusExporterImpl.java:472)
at
org.apache.cloudstack.metrics.PrometheusExporterServerImpl$ExporterHandler.handle(PrometheusExporterServerImpl.java:56)
at
jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)
at
jdk.httpserver/sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:82)
at
jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:80)
at
jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:848)
at
jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)
at
jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:817)
at
jdk.httpserver/sun.net.httpserver.ServerImpl$DefaultExecutor.execute(ServerImpl.java:201)
at
jdk.httpserver/sun.net.httpserver.ServerImpl$Dispatcher.handle(ServerImpl.java:560)
at
jdk.httpserver/sun.net.httpserver.ServerImpl$Dispatcher.run(ServerImpl.java:526)
at java.base/java.lang.Thread.run(Thread.java:829)
~~~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]