[pve-devel] [PATCH cluster/qemu-server/container 1/1] add purge_rrd_data sub

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Nov 13 14:18:51 CET 2024


On November 4, 2024 7:32 pm, Bennet Gallein wrote:
> Signed-off-by: Bennet Gallein <me at bennetgallein.de>
> ---
>  src/PVE/RRD.pm | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/src/PVE/RRD.pm b/src/PVE/RRD.pm
> index 5d4abc9..636226c 100644
> --- a/src/PVE/RRD.pm
> +++ b/src/PVE/RRD.pm
> @@ -6,6 +6,26 @@ use RRDs;
>  
>  use PVE::Tools;
>  
> +sub purge_rrd_data {
> +    my ($rrdname)  = @_;
> +
> +    my $rrddir = "/var/lib/rrdcached/db";
> +
> +    my $rrd = "$rrddir/$rrdname";
> +
> +    my @args = ();
> +    my $socket = "/var/run/rrdcached.sock";
> +    push @args, "--daemon" => "unix:$socket" if -S $socket;
> +
> +    # flush cached RRDs
> +    RRDs::flushcached($rrd, @args);

isn't this racy - if another RRD update happens between this

> +
> +    my $err = RRDs::error;
> +    die "RRD error flushing pre-purge: $err\n" if $err;
> +
> +    unlink($rrd) or die("ERROR deleting RRD file");

and this?

I think this would need to be broadcasted as well (and handled in
pmxcfs? that would also allow discarding broadcasts with earlier
timestamps), else RRD data on other nodes in a cluster is still around
(see PVE/Service/pvestatd.pm in pve-manager , and src/pmxcfs/status.c
here in pve-cluster)..

> +}
> +
>  sub create_rrd_data {
>      my ($rrdname, $timeframe, $cf) = @_;
>  
> -- 
> 2.39.5
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




More information about the pve-devel mailing list