public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH cluster/qemu-server/container 0/1] fix: #5266 - RRD cleanup when pruning
@ 2024-11-04 18:32 Bennet Gallein
  2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] add prune_rrd_data to destroy with purge Bennet Gallein
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Bennet Gallein @ 2024-11-04 18:32 UTC (permalink / raw)
  To: pve-devel

currently, when removing a VM and recreating it, the rdd data from the previous VMID gets displayed in the API / GUI.
This is confusing for short-living VMs which get redeployed on a regular basis.

This patch adds a prune_rrd_data sub to the pve-cluster package, which also holds the subs for creating and getting data from rrd databases.

The new function is then called in qemu-server and pve-container if the destroy API is called with the purge parameter set.


I am new to this git mail stuff, so forgive me any errors.

Bennet Gallein (1):
  add prune_rrd_data to destroy with purge

 src/PVE/API2/LXC.pm | 1 +
 1 file changed, 1 insertion(+)

-- 
2.39.5


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


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

* [pve-devel] [PATCH cluster/qemu-server/container 1/1] add prune_rrd_data to destroy with purge
  2024-11-04 18:32 [pve-devel] [PATCH cluster/qemu-server/container 0/1] fix: #5266 - RRD cleanup when pruning Bennet Gallein
@ 2024-11-04 18:32 ` Bennet Gallein
  2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] add purge_rrd_data sub Bennet Gallein
  2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] integrate prune_rrd_data function to destroy with prune Bennet Gallein
  2 siblings, 0 replies; 5+ messages in thread
From: Bennet Gallein @ 2024-11-04 18:32 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Bennet Gallein <me@bennetgallein.de>
---
 src/PVE/API2/LXC.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 213e518..6e953db 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -787,6 +787,7 @@ __PACKAGE__->register_method({
 	        print "purging CT $vmid from related configurations..\n";
 		PVE::ReplicationConfig::remove_vmid_jobs($vmid);
 		PVE::VZDump::Plugin::remove_vmid_from_backup_jobs($vmid);
+		PVE::RRD::purge_rrd_data("pve2-vm/$vmid");
 
 		if ($ha_managed) {
 		    PVE::HA::Config::delete_service_from_config("ct:$vmid");
-- 
2.39.5


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


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

* [pve-devel] [PATCH cluster/qemu-server/container 1/1] add purge_rrd_data sub
  2024-11-04 18:32 [pve-devel] [PATCH cluster/qemu-server/container 0/1] fix: #5266 - RRD cleanup when pruning Bennet Gallein
  2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] add prune_rrd_data to destroy with purge Bennet Gallein
@ 2024-11-04 18:32 ` Bennet Gallein
  2024-11-13 13:18   ` Fabian Grünbichler
  2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] integrate prune_rrd_data function to destroy with prune Bennet Gallein
  2 siblings, 1 reply; 5+ messages in thread
From: Bennet Gallein @ 2024-11-04 18:32 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Bennet Gallein <me@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);
+
+    my $err = RRDs::error;
+    die "RRD error flushing pre-purge: $err\n" if $err;
+
+    unlink($rrd) or die("ERROR deleting RRD file");
+}
+
 sub create_rrd_data {
     my ($rrdname, $timeframe, $cf) = @_;
 
-- 
2.39.5


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


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

* [pve-devel] [PATCH cluster/qemu-server/container 1/1] integrate prune_rrd_data function to destroy with prune
  2024-11-04 18:32 [pve-devel] [PATCH cluster/qemu-server/container 0/1] fix: #5266 - RRD cleanup when pruning Bennet Gallein
  2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] add prune_rrd_data to destroy with purge Bennet Gallein
  2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] add purge_rrd_data sub Bennet Gallein
@ 2024-11-04 18:32 ` Bennet Gallein
  2 siblings, 0 replies; 5+ messages in thread
From: Bennet Gallein @ 2024-11-04 18:32 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Bennet Gallein <me@bennetgallein.de>
---
 PVE/API2/Qemu.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 848001b6..b70c51e7 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2328,6 +2328,7 @@ __PACKAGE__->register_method({
 		    print "purging VM $vmid from related configurations..\n";
 		    PVE::ReplicationConfig::remove_vmid_jobs($vmid);
 		    PVE::VZDump::Plugin::remove_vmid_from_backup_jobs($vmid);
+		    PVE::RRD::purge_rrd_data("pve2-vm/$vmid");
 
 		    if ($ha_managed) {
 			PVE::HA::Config::delete_service_from_config("vm:$vmid");
-- 
2.39.5


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


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

* Re: [pve-devel] [PATCH cluster/qemu-server/container 1/1] add purge_rrd_data sub
  2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] add purge_rrd_data sub Bennet Gallein
@ 2024-11-13 13:18   ` Fabian Grünbichler
  0 siblings, 0 replies; 5+ messages in thread
From: Fabian Grünbichler @ 2024-11-13 13:18 UTC (permalink / raw)
  To: Proxmox VE development discussion

On November 4, 2024 7:32 pm, Bennet Gallein wrote:
> Signed-off-by: Bennet Gallein <me@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@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 


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


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

end of thread, other threads:[~2024-11-13 13:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-04 18:32 [pve-devel] [PATCH cluster/qemu-server/container 0/1] fix: #5266 - RRD cleanup when pruning Bennet Gallein
2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] add prune_rrd_data to destroy with purge Bennet Gallein
2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] add purge_rrd_data sub Bennet Gallein
2024-11-13 13:18   ` Fabian Grünbichler
2024-11-04 18:32 ` [pve-devel] [PATCH cluster/qemu-server/container 1/1] integrate prune_rrd_data function to destroy with prune Bennet Gallein

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