public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH v2 manager] fix #3440: influxdb: remove duplicate vmid tag
@ 2021-05-26  9:25 Lorenz Stechauner
  2021-05-26 15:39 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Lorenz Stechauner @ 2021-05-26  9:25 UTC (permalink / raw)
  To: pve-devel

remove vmid from data part, it is already contained in object part.
this is accomplished by adding the parameter $excluded to
build_influxdb_payload().

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
---
changes to v1:
- not using `delete` anymore
- added parameter `excluded` to build_influxdb_payload()

 PVE/Status/InfluxDB.pm | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/PVE/Status/InfluxDB.pm b/PVE/Status/InfluxDB.pm
index 9e4b0d96..b2bd25d2 100644
--- a/PVE/Status/InfluxDB.pm
+++ b/PVE/Status/InfluxDB.pm
@@ -94,7 +94,8 @@ sub update_qemu_status {
     }
     $object =~ s/\s/\\ /g;
 
-    build_influxdb_payload($class, $txn, $data, $ctime, $object);
+    # Duplicate keys may result in unwanted behavior
+    build_influxdb_payload($class, $txn, $data, $ctime, $object, { 'vmid' => 1 });
 }
 
 sub update_lxc_status {
@@ -108,7 +109,8 @@ sub update_lxc_status {
     }
     $object =~ s/\s/\\ /g;
 
-    build_influxdb_payload($class, $txn, $data, $ctime, $object);
+    # Duplicate keys may result in unwanted behavior
+    build_influxdb_payload($class, $txn, $data, $ctime, $object, { 'vmid' => 1 });
 }
 
 sub update_storage_status {
@@ -246,11 +248,12 @@ sub test_connection {
 }
 
 sub build_influxdb_payload {
-    my ($class, $txn, $data, $ctime, $tags, $measurement, $instance) = @_;
+    my ($class, $txn, $data, $ctime, $tags, $excluded, $measurement, $instance) = @_;
 
     my @values = ();
 
     foreach my $key (sort keys %$data) {
+	next if defined($excluded) && $excluded->{$key};
 	my $value = $data->{$key};
 	next if !defined($value);
 
@@ -264,9 +267,9 @@ sub build_influxdb_payload {
 	    # value is a hash
 
 	    if (!defined($measurement)) {
-		build_influxdb_payload($class, $txn, $value, $ctime, $tags, $key);
+		build_influxdb_payload($class, $txn, $value, $ctime, $tags, $excluded, $key);
 	    } elsif(!defined($instance)) {
-		build_influxdb_payload($class, $txn, $value, $ctime, $tags, $measurement, $key);
+		build_influxdb_payload($class, $txn, $value, $ctime, $tags, $excluded, $measurement, $key);
 	    } else {
 		push @values, get_recursive_values($value);
 	    }
-- 
2.20.1





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

* [pve-devel] applied: [PATCH v2 manager] fix #3440: influxdb: remove duplicate vmid tag
  2021-05-26  9:25 [pve-devel] [PATCH v2 manager] fix #3440: influxdb: remove duplicate vmid tag Lorenz Stechauner
@ 2021-05-26 15:39 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-05-26 15:39 UTC (permalink / raw)
  To: Proxmox VE development discussion, Lorenz Stechauner

On 26.05.21 11:25, Lorenz Stechauner wrote:
> remove vmid from data part, it is already contained in object part.
> this is accomplished by adding the parameter $excluded to
> build_influxdb_payload().
> 
> Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
> ---
> changes to v1:
> - not using `delete` anymore
> - added parameter `excluded` to build_influxdb_payload()
> 

nicer approach indeed.

>  PVE/Status/InfluxDB.pm | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
>

applied, thanks! Followed up with a slight change in comment message, as
the old one read a bit to generic to me.




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

end of thread, other threads:[~2021-05-26 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26  9:25 [pve-devel] [PATCH v2 manager] fix #3440: influxdb: remove duplicate vmid tag Lorenz Stechauner
2021-05-26 15:39 ` [pve-devel] applied: " Thomas Lamprecht

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