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 C49266A5C2 for ; Mon, 15 Mar 2021 09:15:04 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BA5D61DA91 for ; Mon, 15 Mar 2021 09:15:04 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 BC8191DA76 for ; Mon, 15 Mar 2021 09:15:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 705074259C for ; Mon, 15 Mar 2021 09:15:03 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Date: Mon, 15 Mar 2021 09:14:55 +0100 Message-Id: <20210315081457.3543519-3-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210315081457.3543519-1-t.lamprecht@proxmox.com> References: <20210315081457.3543519-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.048 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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 manager 3/5] metrics: influx: do not error out when credendtials could not be loaded 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: Mon, 15 Mar 2021 08:15:04 -0000 Not a hard error, some network box (proxy) down the line could add it for us, or it could be just not required, so ... Signed-off-by: Thomas Lamprecht --- PVE/Status/InfluxDB.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PVE/Status/InfluxDB.pm b/PVE/Status/InfluxDB.pm index 712a30ff..137aec1b 100644 --- a/PVE/Status/InfluxDB.pm +++ b/PVE/Status/InfluxDB.pm @@ -208,7 +208,7 @@ sub test_connection { my $ua = LWP::UserAgent->new(); $ua->timeout($cfg->{timeout} // 1); # in the initial add connection test, the token may still be in $cfg - my $token = $cfg->{token} // get_credentials($id); + my $token = $cfg->{token} // get_credentials($id, 1); if (defined($token)) { $ua->default_header("Authorization" => "Token $token"); } @@ -330,11 +330,14 @@ sub set_credentials { } sub get_credentials { - my ($id) = @_; + my ($id, $silent) = @_; my $cred_file = cred_file_name($id); - return PVE::Tools::file_get_contents($cred_file); + my $creds = eval { PVE::Tools::file_get_contents($cred_file) }; + warn "could not load credentials for '$id': $@\n" if $@ && !$silent; + + return $creds; } sub on_add_hook { -- 2.29.2