HDDS-7045. Election info is out of date in Recon
What changes were proposed in this pull request?
The Last Leader Election and No. of Elections columns in the Pipelines page had incorrect or no data previously. This issue is caused by a few small things. These columns only have data, if any metrics service providers like Prometheus is configured, which is assumable from a comment in the code. I added a tooltip to these columns with this information and if no metrics service provider is configured in the cluster, the columns will show NA.
If you configured Prometheus the No. of Elections had data, but the Last Leader Election didn't. This happened, because the Last Leader Election's metric name was incorrect. lastLeaderElapsedTime was added in this RATIS-1049 to Ratis, but that seemed to be 0 for every case. I found lastLeaderElectionElapsedTime metric in Ratis which gave back the elapsed in milliseconds since a datanode was elected in a pipeline, so I used that. The method that queried the right metric from the provider didn't queried it correctly, as it always returned the first metric for each query. So I made two methods for each metric. For the No. of Elections I asked for a pipeline's all metrics, so I got as many metrics as many datanodes are in the pipeline. As each metric gives me how many times that datanode was elected in the pipeline, I summed up these. For the Last Leader Election I asked for the pipeline's leader node's value as that shows me how much time elapsed since that datanode was last elected in the pipeline.
I also changed some examples in files as you need to add http://prometheus:9090 (not localhost) if you want to add Prometheus's endpoint.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-7045
How was this patch tested?
I tested it locally in the compose/ozone environment with and without Prometheus configured.
https://github.com/dombizita/ozone/actions/runs/2834395620