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 0A6E1B80A6 for ; Wed, 6 Mar 2024 16:49:47 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E82521B9E8 for ; Wed, 6 Mar 2024 16:49:46 +0100 (CET) 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 for ; Wed, 6 Mar 2024 16:49:46 +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 064644883A for ; Wed, 6 Mar 2024 16:49:46 +0100 (CET) Message-ID: Date: Wed, 6 Mar 2024 16:49:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Proxmox Backup Server development discussion , Filip Schauer , Wolfgang Bumiller References: <20240305135645.96347-1-f.schauer@proxmox.com> From: Max Carrara In-Reply-To: <20240305135645.96347-1-f.schauer@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.003 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_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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pbs-devel] [PATCH v4 vma-to-pbs 0/6] Implement vma-to-pbs tool X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Mar 2024 15:49:47 -0000 On 3/5/24 14:56, Filip Schauer wrote: > Implement a tool to import VMA files into a Proxmox Backup Server First of all, I get that patches 1-3 have been applied already, but I still wanted to point out some things in patch 1. How did you build and test this series? proxmox-schema is now at version 3, but proxmox-backup-qemu still requires version 2. Manually installing version 2 breaks some other dependencies - resolving them by hand was honestly too tedious at the moment. If there's any help needed to bump the version, let me know; I might be able to lend a hand there (@Wolfgang). Regarding the code itself, I really like the overall approach a lot, but IMHO the code needs a style refresher. Some things would benefit from being broken up into smaller parts to reduce the overall complexity for a given function - makes things easier to parse and follow (and also easier to debug in case something goes wrong). Additionally, error handling gets *much* easier that way; more below. There are also some bits that could be de-duplicated and some things regarding generics and dynamic dispatch - it's best if you read the comments inline. Regarding error handling: A recurring theme is that `anyhow` isn't utilized fully - it's really great that you got rid of a lot of `unwrap()`s later in the series, but "idiomatic" `anyhow` is used best with `anyhow::Context` [0] and generous use of the `?` operator. Smaller functions have the benefit that they define an "error handling boundary" of some sort, if they return `Result`. It's often better to then add `Context` to those helper functions - that way you can also avoid adding `Context` to *every* single little instance where you might be doing something in particular. See comments inline, in particular patch 5, for a better explanation. Also, sorry if this all seems a little excessive! I wanted to be as thorough as possible. [0]: https://docs.rs/anyhow/latest/anyhow/trait.Context.html