public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-cluster v3] fix #6615: rrd: only return last entry if populated
@ 2025-08-27  9:04 Hannes Laimer
  2025-10-22 12:17 ` Fiona Ebner
  0 siblings, 1 reply; 2+ messages in thread
From: Hannes Laimer @ 2025-08-27  9:04 UTC (permalink / raw)
  To: pve-devel

RRD fetch can include the latest bucket before metrics are flushed,
resulting in entries with only a timestamp.

This now only returns the last entry if it contains at least one value.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
v3, thanks @Dominik:
 - only remove last entry if empty, not all empty ones

 src/PVE/RRD.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/PVE/RRD.pm b/src/PVE/RRD.pm
index 8fe1927..5a23889 100644
--- a/src/PVE/RRD.pm
+++ b/src/PVE/RRD.pm
@@ -81,6 +81,12 @@ sub create_rrd_data {
         push @$res, $entry;
     }
 
+    # The newest bucket can still be empty right after a boundary.
+    if (@$res) {
+        # only contains 'time'
+        pop @$res if (scalar(keys %{$res->[-1]}) == 1);
+    }
+
     return $res;
 }
 
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pve-devel] [PATCH pve-cluster v3] fix #6615: rrd: only return last entry if populated
  2025-08-27  9:04 [pve-devel] [PATCH pve-cluster v3] fix #6615: rrd: only return last entry if populated Hannes Laimer
@ 2025-10-22 12:17 ` Fiona Ebner
  0 siblings, 0 replies; 2+ messages in thread
From: Fiona Ebner @ 2025-10-22 12:17 UTC (permalink / raw)
  To: Proxmox VE development discussion, Hannes Laimer

Am 27.08.25 um 11:04 AM schrieb Hannes Laimer:
> RRD fetch can include the latest bucket before metrics are flushed,
> resulting in entries with only a timestamp.
> 
> This now only returns the last entry if it contains at least one value.
> 
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>

Tested-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>

With minor style nits below, but could also be applied as is:

> ---
> v3, thanks @Dominik:
>  - only remove last entry if empty, not all empty ones
> 
>  src/PVE/RRD.pm | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/PVE/RRD.pm b/src/PVE/RRD.pm
> index 8fe1927..5a23889 100644
> --- a/src/PVE/RRD.pm
> +++ b/src/PVE/RRD.pm
> @@ -81,6 +81,12 @@ sub create_rrd_data {
>          push @$res, $entry;
>      }
>  
> +    # The newest bucket can still be empty right after a boundary.
> +    if (@$res) {

Style nit: I'd prefer scalar($res->@*) > 0 to be explicit

> +        # only contains 'time'
> +        pop @$res if (scalar(keys %{$res->[-1]}) == 1);

Style nit: we don't usually use parentheses for post-if
Style nit: I'd prefer $res->[-1]->%* so you don't have to mentally keep
track of the % when reading

> +    }
> +
>      return $res;
>  }
>  


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-22 12:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-27  9:04 [pve-devel] [PATCH pve-cluster v3] fix #6615: rrd: only return last entry if populated Hannes Laimer
2025-10-22 12:17 ` Fiona Ebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal