public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lorenz Stechauner <l.stechauner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 manager] fix #3440: influxdb: remove duplicate vmid tag
Date: Wed, 26 May 2021 11:25:11 +0200	[thread overview]
Message-ID: <20210526092511.45020-1-l.stechauner@proxmox.com> (raw)

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





             reply	other threads:[~2021-05-26  9:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26  9:25 Lorenz Stechauner [this message]
2021-05-26 15:39 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210526092511.45020-1-l.stechauner@proxmox.com \
    --to=l.stechauner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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