From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 7966F1FF16B for ; Tue, 9 Sep 2025 10:26:08 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D13E91DD9; Tue, 9 Sep 2025 10:26:11 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Tue, 9 Sep 2025 10:25:51 +0200 Message-ID: <20250909082608.1018103-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.2 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.599 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_BADIPHTTP 2 Due to the Storm Bot Network, IPs in emails is bad KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_SHORT 0.001 Use of a URL Shortener for very short URL NORMAL_HTTP_TO_IP 0.001 URI host has a public dotted-decimal IPv4 address NUMERIC_HTTP_ADDR 1.242 Uses a numeric IP address in URL SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record WEIRD_PORT 0.001 Uses non-standard port number for HTTP Subject: [pdm-devel] [RFC PATCH datacenter-manager] server: api: resources: use root cause for errors for remote fetching X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" when we can't reach a remote for any reason, we want to return the error as a string here over the API. Since most errors that can occur here are client/network related (wrong credentials, no route to host, timeout, etc.) converting this error directly to a string gives us errors like: `client error (Connect)` which is not really helpful most of the time. Instead if we use the `root_cause()`, we get the most underlying error e.g. `error connecting to https://0.0.0.0:8006/ - tcp connect error: No route to host (os error 113)` which is much more helpful. We could also think about printing the whole error chain, but in my test cases here this was not more helpful, e.g. i got two times the above `client error (Connect)` and once the root cause from above. Signed-off-by: Dominik Csapak --- server/src/api/resources.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs index 98c4dea..cca8bcb 100644 --- a/server/src/api/resources.rs +++ b/server/src/api/resources.rs @@ -245,7 +245,7 @@ pub(crate) async fn get_resources_impl( let handle = tokio::spawn(async move { let (mut resources, error) = match get_resources_for_remote(remote, max_age).await { Ok(resources) => (resources, None), - Err(error) => (Vec::new(), Some(error.to_string())), + Err(error) => (Vec::new(), Some(error.root_cause().to_string())), }; if remotes_only { -- 2.47.2 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel