From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D4E0272C8F for ; Wed, 26 May 2021 11:25:36 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CC59CFA30 for ; Wed, 26 May 2021 11:25:36 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 505A8FA26 for ; Wed, 26 May 2021 11:25:36 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id ECDF546666 for ; Wed, 26 May 2021 11:25:35 +0200 (CEST) From: Lorenz Stechauner To: pve-devel@lists.proxmox.com Date: Wed, 26 May 2021 11:25:11 +0200 Message-Id: <20210526092511.45020-1-l.stechauner@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.342 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 manager] fix #3440: influxdb: remove duplicate vmid tag X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 May 2021 09:25:36 -0000 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 --- 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