public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Max Carrara <m.carrara@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	Filip Schauer <f.schauer@proxmox.com>,
	Wolfgang Bumiller <w.bumiller@proxmox.com>
Subject: Re: [pbs-devel] [PATCH v4 vma-to-pbs 0/6] Implement vma-to-pbs tool
Date: Wed, 6 Mar 2024 16:49:45 +0100	[thread overview]
Message-ID: <b6269508-6ed3-4424-87f8-e92202d91898@proxmox.com> (raw)
In-Reply-To: <20240305135645.96347-1-f.schauer@proxmox.com>

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<T, anyhow::Error>`.

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





  parent reply	other threads:[~2024-03-06 15:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 13:56 Filip Schauer
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 1/6] Initial commit Filip Schauer
2024-03-06 15:49   ` Max Carrara
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 2/6] cargo fmt Filip Schauer
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 3/6] bump proxmox-backup-qemu Filip Schauer
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 4/6] Add the ability to provide credentials via files Filip Schauer
2024-03-06 15:49   ` Max Carrara
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 5/6] Add support for streaming the VMA file via stdin Filip Schauer
2024-03-06 15:49   ` Max Carrara
2024-03-12 14:04     ` Filip Schauer
2024-03-05 13:56 ` [pbs-devel] [PATCH v4 vma-to-pbs 6/6] Add a fallback for the --fingerprint argument Filip Schauer
2024-03-06 15:49 ` Max Carrara [this message]
2024-03-06 15:57   ` [pbs-devel] [PATCH v4 vma-to-pbs 0/6] Implement vma-to-pbs tool Wolfgang Bumiller
2024-03-20 14:18 ` Filip Schauer

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=b6269508-6ed3-4424-87f8-e92202d91898@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=f.schauer@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=w.bumiller@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